From 4f01c099fbfa9b0a2e54091e97857aaf380cf7fc Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org> Date: Fri, 14 Jun 2013 10:52:09 +0100 Subject: [PATCH] Issue #1989230 by ParisLiakos, alexpott: Update to Symfony 2.3. --- composer.json | 18 +- composer.lock | 307 ++++--- core/vendor/autoload.php | 2 +- core/vendor/composer/ClassLoader.php | 1 + core/vendor/composer/autoload_classmap.php | 1 + core/vendor/composer/autoload_namespaces.php | 1 + core/vendor/composer/autoload_real.php | 6 +- core/vendor/composer/installed.json | 575 ++++++------ .../kriswallsmith/assetic/CHANGELOG-1.1.md | 19 +- core/vendor/kriswallsmith/assetic/Gemfile | 5 + core/vendor/kriswallsmith/assetic/README.md | 1 + .../kriswallsmith/assetic/composer.json | 16 +- .../vendor/kriswallsmith/assetic/package.json | 12 + .../src/Assetic/Asset/AssetCollection.php | 6 + .../assetic/src/Assetic/Asset/FileAsset.php | 6 +- .../assetic/src/Assetic/Asset/GlobAsset.php | 5 +- .../assetic/src/Assetic/Asset/HttpAsset.php | 13 +- .../assetic/src/Assetic/AssetManager.php | 10 +- .../assetic/src/Assetic/AssetWriter.php | 72 +- .../Extension/Twig/AsseticExtension.php | 2 +- .../src/Assetic/Factory/LazyAssetManager.php | 38 + .../Factory/Worker/CacheBustingWorker.php | 66 +- .../src/Assetic/Filter/BaseCssFilter.php | 55 +- .../src/Assetic/Filter/BaseNodeFilter.php | 1 + .../src/Assetic/Filter/BaseProcessFilter.php | 7 + .../src/Assetic/Filter/CompassFilter.php | 13 +- .../src/Assetic/Filter/CssEmbedFilter.php | 9 +- .../src/Assetic/Filter/CssImportFilter.php | 9 +- .../Filter/DependencyExtractorInterface.php | 34 + .../Assetic/Filter/EmberPrecompileFilter.php | 83 ++ .../GoogleClosure/CompilerApiFilter.php | 2 +- .../assetic/src/Assetic/Filter/LessFilter.php | 101 ++- .../src/Assetic/Filter/LessphpFilter.php | 54 +- .../src/Assetic/Filter/PhpCssEmbedFilter.php | 9 +- .../src/Assetic/Filter/RooleFilter.php | 73 ++ .../src/Assetic/Filter/Sass/SassFilter.php | 63 +- .../src/Assetic/Filter/ScssphpFilter.php | 9 +- .../src/Assetic/Filter/SprocketsFilter.php | 9 +- .../src/Assetic/Filter/StylusFilter.php | 10 +- .../src/Assetic/Filter/UglifyJs2Filter.php | 30 + .../assetic/src/Assetic/Util/CssUtils.php | 111 +++ .../assetic/src/Assetic/Util/LessUtils.php | 23 + .../assetic/src/Assetic/Util/PathUtils.php | 40 - .../assetic/src/Assetic/Util/VarUtils.php | 82 ++ .../phpunit/php-code-coverage/.gitignore | 2 + .../php-code-coverage/ChangeLog.markdown | 14 +- .../php-code-coverage/PHP/CodeCoverage.php | 4 +- .../PHP/CodeCoverage/Autoload.php | 4 + .../PHP/CodeCoverage/Autoload.php.in | 4 + .../PHP/CodeCoverage/Filter.php | 4 + .../PHP/CodeCoverage/Util.php | 38 +- .../PHP/CodeCoverage/Version.php | 2 +- .../phpunit/php-code-coverage/README.markdown | 48 +- .../Tests/PHP/CodeCoverage/FilterTest.php | 4 + .../Tests/PHP/CodeCoverage/UtilTest.php | 20 +- .../Tests/PHP/CodeCoverageTest.php | 71 +- .../CoverageFunctionParenthesesTest.php | 11 + ...erageFunctionParenthesesWhitespaceTest.php | 11 + .../_files/CoverageMethodParenthesesTest.php | 12 + ...overageMethodParenthesesWhitespaceTest.php | 12 + .../source_with_oneline_annotations.php | 22 + .../phpunit/php-code-coverage/composer.json | 3 + .../phpunit/php-code-coverage/package.xml | 6 +- core/vendor/phpunit/phpunit/.gitignore | 2 + core/vendor/phpunit/phpunit/ChangeLog.md | 17 + .../phpunit/phpunit/PHPUnit/Autoload.php | 5 +- .../phpunit/phpunit/PHPUnit/Autoload.php.in | 4 +- .../phpunit/PHPUnit/Framework/Assert.php | 91 +- .../PHPUnit/Framework/Assert/Functions.php | 823 ++++++++++++++---- .../PHPUnit/Framework/Constraint/IsJson.php | 109 +++ .../Framework/Constraint/JsonMatches.php | 16 - .../JsonMatches/ErrorMessageProvider.php | 16 +- .../PHPUnit/Framework/Constraint/SameSize.php | 2 +- .../phpunit/PHPUnit/Framework/TestCase.php | 2 +- .../phpunit/PHPUnit/Framework/TestFailure.php | 2 +- .../phpunit/PHPUnit/Runner/Version.php | 2 +- .../phpunit/PHPUnit/Util/Configuration.php | 25 +- .../phpunit/PHPUnit/Util/ErrorHandler.php | 8 +- .../phpunit/phpunit/PHPUnit/Util/Test.php | 1 + .../Tests/Framework/Assert/FunctionsTest.php | 80 ++ .../phpunit/Tests/Framework/AssertTest.php | 66 +- .../JsonMatches/ErrorMessageProviderTest.php | 14 +- .../Framework/Constraint/JsonMatchesTest.php | 1 - .../Tests/Framework/ConstraintTest.php | 93 ++ .../Tests/Framework/TestFailureTest.php | 68 ++ .../phpunit/phpunit/Tests/Util/TestTest.php | 4 + .../phpunit/Tests/_files/ExceptionTest.php | 5 + .../phpunit/phpunit/build/assertions.php | 2 +- core/vendor/phpunit/phpunit/composer.json | 2 +- core/vendor/phpunit/phpunit/package.xml | 7 +- core/vendor/phpunit/phpunit/phpdox.xml.dist | 4 +- core/vendor/phpunit/phpunit/phpunit.xml.dist | 4 +- .../Cmf/Component/Routing/ChainRouter.php | 3 + .../Routing/RouteObjectInterface.php | 2 +- .../Enhancer/FieldByClassEnhancerTest.php | 4 +- .../Tests/Enhancer/FieldMapEnhancerTest.php | 4 +- .../Enhancer/FieldPresenceEnhancerTest.php | 4 +- .../Tests/NestedMatcher/UrlMatcherTest.php | 5 - .../Routing/Tests/Routing/ChainRouterTest.php | 33 + .../Routing/ContentAwareGeneratorTest.php | 24 +- .../Cmf/Component/Routing/composer.json | 4 +- .../Component/ClassLoader/CHANGELOG.md | 5 + .../ClassLoader/ClassCollectionLoader.php | 2 +- .../Component/ClassLoader/ClassLoader.php | 16 +- .../ClassLoader/ClassMapGenerator.php | 2 +- .../Component/ClassLoader/MapClassLoader.php | 8 - .../ClassLoader/Tests/ClassLoaderTest.php | 4 +- .../Tests/ClassMapGeneratorTest.php | 2 +- .../Tests/DebugClassLoaderTest.php | 1 + .../Tests/UniversalClassLoaderTest.php | 4 +- .../ClassLoader/UniversalClassLoader.php | 4 - .../ClassLoader/WinCacheClassLoader.php | 133 +++ .../Component/ClassLoader/composer.json | 2 +- .../debug/Symfony/Component/Debug/.gitignore | 3 + .../Symfony/Component/Debug/CHANGELOG.md | 7 + .../debug/Symfony/Component/Debug/Debug.php | 58 ++ .../Symfony/Component/Debug/ErrorHandler.php | 165 ++++ .../Debug/Exception/ContextErrorException.php | 36 + .../Debug/Exception/FatalErrorException.php | 21 + .../Debug/Exception/FlattenException.php | 277 ++++++ .../Component/Debug/ExceptionHandler.php | 316 +++++++ .../debug/Symfony/Component/Debug/LICENSE | 19 + .../debug/Symfony/Component/Debug/README.md | 40 + .../Debug/Tests}/ErrorHandlerTest.php | 4 +- .../Tests/Exception/FlattenExceptionTest.php | 4 +- .../Debug/Tests}/ExceptionHandlerTest.php | 4 +- .../Symfony/Component/Debug/composer.json | 40 + .../Symfony/Component/Debug/phpunit.xml.dist | 29 + .../Compiler/CheckCircularReferencesPass.php | 10 +- .../Compiler/CheckReferenceValidityPass.php | 4 +- .../Compiler/ResolveInvalidReferencesPass.php | 4 +- .../DependencyInjection/Container.php | 76 +- .../DependencyInjection/ContainerBuilder.php | 252 +++++- .../DependencyInjection/Definition.php | 56 ++ .../DependencyInjection/Dumper/PhpDumper.php | 262 ++++-- .../DependencyInjection/Dumper/XmlDumper.php | 23 +- .../DependencyInjection/Dumper/YamlDumper.php | 27 +- .../Exception/InactiveScopeException.php | 4 +- .../ParameterCircularReferenceException.php | 4 +- .../Exception/ParameterNotFoundException.php | 23 +- .../ScopeCrossingInjectionException.php | 4 +- .../ScopeWideningInjectionException.php | 4 +- .../ServiceCircularReferenceException.php | 4 +- .../Exception/ServiceNotFoundException.php | 13 +- .../Extension/Extension.php | 2 +- .../Instantiator/InstantiatorInterface.php | 37 + .../Instantiator/RealServiceInstantiator.php | 33 + .../LazyProxy/PhpDumper/DumperInterface.php | 51 ++ .../LazyProxy/PhpDumper/NullDumper.php | 47 + .../Loader/XmlFileLoader.php | 2 +- .../Loader/YamlFileLoader.php | 26 +- .../schema/dic/services/services-1.0.xsd | 2 + .../ParameterBag/ParameterBag.php | 14 +- .../CheckCircularReferencesPassTest.php | 19 +- .../Tests/ContainerBuilderTest.php | 164 ++++ .../Tests/ContainerTest.php | 41 +- .../Tests/DefinitionTest.php | 26 +- .../Tests/Dumper/PhpDumperTest.php | 14 + .../Tests/Fixtures/containers/container9.php | 10 + .../Tests/Fixtures/graphviz/services9.dot | 3 + .../Tests/Fixtures/includes/classes.php | 5 + .../Tests/Fixtures/includes/createphar.php | 2 +- .../Tests/Fixtures/php/services10.php | 3 + .../Tests/Fixtures/php/services9.php | 59 +- .../Tests/Fixtures/php/services9_compiled.php | 54 +- .../Tests/Fixtures/xml/services2.xml | 2 +- .../Tests/Fixtures/xml/services6.xml | 1 + .../Tests/Fixtures/xml/services9.xml | 7 + .../Tests/Fixtures/yaml/services6.yml | 5 + .../Tests/Fixtures/yaml/services9.yml | 12 + .../RealServiceInstantiatorTest.php | 37 + .../LazyProxy/PhpDumper/NullDumperTest.php | 35 + .../Tests/Loader/XmlFileLoaderTest.php | 4 + .../Tests/Loader/YamlFileLoaderTest.php | 4 + .../Tests/ParameterBag/ParameterBagTest.php | 39 +- .../DependencyInjection/composer.json | 9 +- .../Component/EventDispatcher/composer.json | 6 +- .../HttpFoundation/ApacheRequest.php | 8 - .../HttpFoundation/BinaryFileResponse.php | 4 +- .../Component/HttpFoundation/CHANGELOG.md | 9 + .../Component/HttpFoundation/Cookie.php | 4 +- .../Component/HttpFoundation/File/File.php | 14 +- .../File/MimeType/ExtensionGuesser.php | 9 +- .../File/MimeType/FileinfoMimeTypeGuesser.php | 18 +- .../MimeType/MimeTypeExtensionGuesser.php | 67 +- .../File/MimeType/MimeTypeGuesser.php | 21 +- .../HttpFoundation/File/UploadedFile.php | 104 ++- .../Component/HttpFoundation/IpUtils.php | 20 +- .../Component/HttpFoundation/JsonResponse.php | 6 + .../Component/HttpFoundation/Request.php | 139 +-- .../HttpFoundation/RequestMatcher.php | 41 +- .../Component/HttpFoundation/Response.php | 28 +- .../Component/HttpFoundation/ServerBag.php | 3 +- .../Attribute/NamespacedAttributeBag.php | 16 +- .../HttpFoundation/Session/Flash/FlashBag.php | 19 +- .../HttpFoundation/Session/Session.php | 109 --- .../Storage/Handler/PdoSessionHandler.php | 4 +- .../Session/Storage/NativeSessionStorage.php | 57 +- .../Storage/PhpBridgeSessionStorage.php | 69 ++ .../Session/Storage/Proxy/AbstractProxy.php | 15 + .../Tests/BinaryFileResponseTest.php | 7 +- .../HttpFoundation/Tests/CookieTest.php | 7 +- .../Tests/File/UploadedFileTest.php | 42 +- .../HttpFoundation/Tests/IpUtilsTest.php | 10 + .../HttpFoundation/Tests/RequestTest.php | 291 +++++-- .../Tests/ResponseHeaderBagTest.php | 6 +- .../HttpFoundation/Tests/ResponseTest.php | 76 +- .../HttpFoundation/Tests/ResponseTestCase.php | 88 ++ .../Attribute/NamespacedAttributeBagTest.php | 2 + .../Tests/Session/Flash/FlashBagTest.php | 14 - .../Tests/Session/SessionTest.php | 106 --- .../Storage/Handler/PdoSessionHandlerTest.php | 38 + .../Storage/NativeSessionStorageTest.php | 143 ++- .../Storage/PhpBridgeSessionStorageTest.php | 124 +++ .../Storage/Proxy/AbstractProxyTest.php | 79 +- .../Storage/Proxy/SessionHandlerProxyTest.php | 8 +- .../Component/HttpFoundation/composer.json | 2 +- .../Symfony/Component/HttpKernel/CHANGELOG.md | 14 +- .../Symfony/Component/HttpKernel/Client.php | 25 +- .../HttpKernel/Config/FileLocator.php | 10 +- .../Controller/ControllerResolver.php | 8 +- .../DataCollector/ConfigDataCollector.php | 43 +- .../DataCollector/MemoryDataCollector.php | 31 +- .../DataCollector/RequestDataCollector.php | 18 +- .../DataCollector/TimeDataCollector.php | 8 +- .../HttpKernel/Debug/ErrorHandler.php | 111 +-- .../HttpKernel/Debug/ExceptionHandler.php | 266 +----- .../Debug/TraceableEventDispatcher.php | 3 +- .../ContainerAwareHttpKernel.php | 10 +- .../RegisterListenersPass.php | 92 ++ ...rListener.php => ErrorsLoggerListener.php} | 12 +- .../EventListener/ExceptionListener.php | 5 +- .../EventListener/FragmentListener.php | 6 +- .../EventListener/LocaleListener.php | 33 +- .../EventListener/RouterListener.php | 24 +- .../Exception/FatalErrorException.php | 7 +- .../HttpKernel/Exception/FlattenException.php | 258 +----- .../HttpKernel/Fragment/FragmentHandler.php | 74 +- .../Fragment/HIncludeFragmentRenderer.php | 37 +- .../Fragment/InlineFragmentRenderer.php | 32 +- .../HttpCache/EsiResponseCacheStrategy.php | 27 +- .../HttpKernel/HttpCache/HttpCache.php | 17 +- .../Component/HttpKernel/HttpCache/Store.php | 11 +- .../Component/HttpKernel/HttpKernel.php | 18 +- .../Symfony/Component/HttpKernel/Kernel.php | 98 ++- .../Profiler/BaseMemcacheProfilerStorage.php | 4 +- .../Profiler/FileProfilerStorage.php | 13 +- .../Profiler/MemcacheProfilerStorage.php | 2 +- .../Profiler/MongoDbProfilerStorage.php | 2 +- .../HttpKernel/Profiler/Profiler.php | 2 +- .../Component/HttpKernel/Tests/ClientTest.php | 8 +- .../Tests/Config/FileLocatorTest.php | 47 + .../Controller/ControllerResolverTest.php | 10 + .../DataCollector/ConfigDataCollectorTest.php | 2 + .../DataCollector/MemoryDataCollectorTest.php | 35 +- .../RequestDataCollectorTest.php | 8 +- .../DataCollector/TimeDataCollectorTest.php | 58 ++ .../Debug/TraceableEventDispatcherTest.php | 40 + .../ContainerAwareHttpKernelTest.php | 34 +- .../RegisterListenersPassTest.php | 89 ++ .../EventListener/LocaleListenerTest.php | 11 + .../Tests/Fragment/FragmentHandlerTest.php | 37 +- .../Fragment/HIncludeFragmentRendererTest.php | 15 + .../Fragment/InlineFragmentRendererTest.php | 34 +- .../Tests/HttpCache/HttpCacheTest.php | 34 +- .../Component/HttpKernel/Tests/KernelTest.php | 57 +- .../Profiler/AbstractProfilerStorageTest.php | 17 +- .../Profiler/FileProfilerStorageTest.php | 16 +- .../Tests/Profiler/Mock/RedisMock.php | 8 +- .../Component/HttpKernel/composer.json | 21 +- .../Symfony/Component/Process/CHANGELOG.md | 8 + .../Exception/ProcessFailedException.php | 4 +- .../Symfony/Component/Process/Process.php | 234 ++++- .../Component/Process/ProcessBuilder.php | 28 +- .../Component/Process/ProcessUtils.php | 60 ++ .../Process/Tests/AbstractProcessTest.php | 213 ++++- .../Process/Tests/NonStopableProcess.php | 37 + .../Process/Tests/PhpProcessTest.php | 10 +- .../Process/Tests/ProcessBuilderTest.php | 98 ++- .../Tests/ProcessFailedExceptionTest.php | 15 +- .../Process/Tests/ProcessUtilsTest.php | 42 + .../Tests/SigchildDisabledProcessTest.php | 50 ++ .../Tests/SigchildEnabledProcessTest.php | 45 + .../Process/Tests/SignalListener.php | 16 + .../Process/Tests/SimpleProcessTest.php | 51 ++ .../Symfony/Component/Process/composer.json | 2 +- .../Symfony/Component/Routing/CHANGELOG.md | 5 + .../Routing/Generator/UrlGenerator.php | 6 +- .../Routing/Loader/XmlFileLoader.php | 9 +- .../Routing/Loader/YamlFileLoader.php | 17 +- .../Loader/schema/routing/routing-1.0.xsd | 2 +- .../Component/Routing/RequestContext.php | 42 +- .../Symfony/Component/Routing/Route.php | 4 +- .../Component/Routing/RouteCollection.php | 115 +-- .../Symfony/Component/Routing/Router.php | 2 +- .../Routing/Tests/Fixtures/validpattern.xml | 1 + .../Tests/Generator/UrlGeneratorTest.php | 4 +- .../Tests/Loader/XmlFileLoaderTest.php | 1 + .../Matcher/Dumper/DumperCollectionTest.php | 9 + .../Dumper/DumperPrefixCollectionTest.php | 9 + .../Routing/Tests/RouteCollectionTest.php | 2 +- .../Routing/Tests/RouteCompilerTest.php | 2 +- .../Component/Routing/Tests/RouterTest.php | 138 +++ .../Symfony/Component/Routing/composer.json | 10 +- .../Symfony/Component/Serializer/CHANGELOG.md | 6 + .../Serializer/Encoder/DecoderInterface.php | 15 +- .../Serializer/Encoder/JsonDecode.php | 48 +- .../Serializer/Encoder/XmlEncoder.php | 2 +- .../Normalizer/GetSetMethodNormalizer.php | 37 +- .../Component/Serializer/Serializer.php | 24 +- .../Normalizer/GetSetMethodNormalizerTest.php | 51 +- .../Tests/Normalizer/TestDenormalizer.php | 37 + .../Tests/Normalizer/TestNormalizer.php | 37 + .../Serializer/Tests/SerializerTest.php | 22 +- .../Component/Serializer/composer.json | 2 +- .../Symfony/Component/Validator/CHANGELOG.md | 9 + .../Validator/ConstraintValidator.php | 84 -- .../Validator/ConstraintViolation.php | 4 +- .../Validator/ConstraintViolationList.php | 2 +- .../{Min.php => AbstractComparison.php} | 34 +- .../AbstractComparisonValidator.php | 75 ++ .../Component/Validator/Constraints/All.php | 6 +- .../Component/Validator/Constraints/Blank.php | 2 + .../Validator/Constraints/Callback.php | 2 + .../Validator/Constraints/Choice.php | 2 + .../Validator/Constraints/Collection.php | 12 +- .../Constraints/Collection/Optional.php | 15 +- .../Constraints/Collection/Required.php | 15 +- .../Constraints/CollectionValidator.php | 2 +- .../Component/Validator/Constraints/Count.php | 4 +- .../Validator/Constraints/Country.php | 2 + .../Constraints/CountryValidator.php | 4 +- .../Validator/Constraints/Currency.php | 26 + .../Constraints/CurrencyValidator.php | 48 + .../Component/Validator/Constraints/Date.php | 2 + .../Validator/Constraints/DateTime.php | 2 + .../Component/Validator/Constraints/Email.php | 2 + .../Validator/Constraints/EqualTo.php | 22 + .../Constraints/EqualToValidator.php | 28 + .../Validator/Constraints/Existence.php | 27 + .../Component/Validator/Constraints/False.php | 2 + .../Component/Validator/Constraints/File.php | 2 + .../Validator/Constraints/GreaterThan.php | 22 + .../Constraints/GreaterThanOrEqual.php | 22 + .../GreaterThanOrEqualValidator.php | 28 + .../Constraints/GreaterThanValidator.php | 28 + .../Validator/Constraints/GroupSequence.php | 1 + .../Component/Validator/Constraints/Iban.php | 22 + .../Validator/Constraints/IbanValidator.php | 62 ++ .../Validator/Constraints/IdenticalTo.php | 22 + .../Constraints/IdenticalToValidator.php | 28 + .../Component/Validator/Constraints/Ip.php | 1 + .../Component/Validator/Constraints/Isbn.php | 45 + .../Validator/Constraints/IsbnValidator.php | 89 ++ .../Component/Validator/Constraints/Issn.php | 26 + .../Validator/Constraints/IssnValidator.php | 62 ++ .../Validator/Constraints/Language.php | 2 + .../Constraints/LanguageValidator.php | 4 +- .../Validator/Constraints/Length.php | 4 +- .../Validator/Constraints/LessThan.php | 22 + .../Validator/Constraints/LessThanOrEqual.php | 22 + .../Constraints/LessThanOrEqualValidator.php | 28 + .../Constraints/LessThanValidator.php | 28 + .../Validator/Constraints/Locale.php | 2 + .../Validator/Constraints/LocaleValidator.php | 4 +- .../Component/Validator/Constraints/Max.php | 51 -- .../Validator/Constraints/MaxLength.php | 51 -- .../Constraints/MaxLengthValidator.php | 62 -- .../Validator/Constraints/MaxValidator.php | 56 -- .../Validator/Constraints/MinLength.php | 51 -- .../Constraints/MinLengthValidator.php | 62 -- .../Validator/Constraints/MinValidator.php | 61 -- .../Validator/Constraints/NotBlank.php | 2 + .../Constraints/NotBlankValidator.php | 2 + .../Validator/Constraints/NotEqualTo.php | 22 + .../Constraints/NotEqualToValidator.php | 28 + .../Validator/Constraints/NotIdenticalTo.php | 22 + .../Constraints/NotIdenticalToValidator.php | 28 + .../Validator/Constraints/NotNull.php | 2 + .../Component/Validator/Constraints/Null.php | 2 + .../Validator/Constraints/Optional.php | 21 + .../Component/Validator/Constraints/Range.php | 4 +- .../Component/Validator/Constraints/Regex.php | 6 +- .../Validator/Constraints/Required.php | 21 + .../Component/Validator/Constraints/Time.php | 2 + .../Component/Validator/Constraints/True.php | 2 + .../Component/Validator/Constraints/Type.php | 2 + .../Component/Validator/Constraints/Url.php | 2 + .../Component/Validator/Constraints/Valid.php | 4 +- .../Component/Validator/ExecutionContext.php | 130 +-- .../Component/Validator/GraphWalker.php | 236 ----- .../Validator/Mapping/ClassMetadata.php | 2 +- .../Mapping/ClassMetadataFactory.php | 19 +- .../Mapping/ClassMetadataFactoryAdapter.php | 63 -- .../Mapping/ClassMetadataFactoryInterface.php | 30 - .../Validator/Mapping/GetterMetadata.php | 6 +- .../Mapping/Loader/YamlFileLoader.php | 18 +- .../Validator/Mapping/MemberMetadata.php | 54 +- .../Validator/Mapping/PropertyMetadata.php | 11 +- .../Symfony/Component/Validator/README.md | 2 +- .../Tests/ConstraintValidatorTest.php | 71 -- .../AbstractComparisonValidatorTestCase.php | 108 +++ .../Tests/Constraints/CollectionTest.php | 4 +- .../Constraints/CollectionValidatorTest.php | 5 +- .../Constraints/CountryValidatorTest.php | 13 +- .../Constraints/CurrencyValidatorTest.php | 109 +++ .../Constraints/EqualToValidatorTest.php | 57 ++ .../Tests/Constraints/FileValidatorTest.php | 4 +- .../GreaterThanOrEqualValidatorTest.php | 58 ++ .../Constraints/GreaterThanValidatorTest.php | 58 ++ .../Tests/Constraints/IbanValidatorTest.php | 187 ++++ .../Constraints/IdenticalToValidatorTest.php | 60 ++ .../Tests/Constraints/IsbnValidatorTest.php | 223 +++++ .../Tests/Constraints/IssnValidatorTest.php | 220 +++++ .../Constraints/LanguageValidatorTest.php | 13 +- .../LessThanOrEqualValidatorTest.php | 58 ++ .../Constraints/LessThanValidatorTest.php | 57 ++ .../Tests/Constraints/LocaleValidatorTest.php | 13 +- .../Tests/Constraints/LocalizedTestCase.php | 22 - .../Constraints/MaxLengthValidatorTest.php | 140 --- .../Tests/Constraints/MaxValidatorTest.php | 124 --- .../Constraints/MinLengthValidatorTest.php | 140 --- .../Tests/Constraints/MinValidatorTest.php | 121 --- .../Constraints/NotEqualToValidatorTest.php | 57 ++ .../NotIdenticalToValidatorTest.php | 60 ++ .../Validator/Tests/ExecutionContextTest.php | 138 --- .../Validator/Tests/Fixtures/Entity.php | 9 +- .../Validator/Tests/Fixtures/EntityParent.php | 6 + .../Tests/Fixtures/FakeMetadataFactory.php | 4 +- .../Validator/Tests/GraphWalkerTest.php | 592 ------------- .../Mapping/ClassMetadataFactoryTest.php | 25 +- .../Tests/Mapping/GetterMetadataTest.php | 8 + .../Tests/Mapping/Loader/FilesLoaderTest.php | 8 +- .../Mapping/Loader/XmlFileLoaderTest.php | 2 +- .../Mapping/Loader/constraint-mapping.xml | 2 +- .../Tests/Mapping/Loader/withdoctype.xml | 2 +- .../Tests/Mapping/MemberMetadataTest.php | 2 +- .../Tests/Mapping/PropertyMetadataTest.php | 10 + .../Validator/Tests/ValidatorBuilderTest.php | 18 - .../Validator/Tests/ValidatorContextTest.php | 76 -- .../Validator/Tests/ValidatorFactoryTest.php | 193 ---- .../Validator/Tests/ValidatorTest.php | 2 +- .../Component/Validator/ValidationVisitor.php | 21 - .../Validator/ValidationVisitorInterface.php | 10 - .../Symfony/Component/Validator/Validator.php | 16 +- .../Component/Validator/ValidatorBuilder.php | 9 +- .../Validator/ValidatorBuilderInterface.php | 7 +- .../Component/Validator/ValidatorContext.php | 124 --- .../Validator/ValidatorContextInterface.php | 65 -- .../Component/Validator/ValidatorFactory.php | 234 ----- .../Symfony/Component/Validator/composer.json | 16 +- .../yaml/Symfony/Component/Yaml/Parser.php | 32 +- .../Component/Yaml/Tests/InlineTest.php | 2 +- .../Component/Yaml/Tests/ParserTest.php | 30 + .../Symfony/Component/Yaml/Tests/YamlTest.php | 10 - .../yaml/Symfony/Component/Yaml/Yaml.php | 67 +- .../yaml/Symfony/Component/Yaml/composer.json | 2 +- 457 files changed, 11478 insertions(+), 6303 deletions(-) mode change 100755 => 100644 core/vendor/kriswallsmith/assetic/CHANGELOG-1.1.md create mode 100644 core/vendor/kriswallsmith/assetic/Gemfile create mode 100644 core/vendor/kriswallsmith/assetic/package.json create mode 100644 core/vendor/kriswallsmith/assetic/src/Assetic/Filter/DependencyExtractorInterface.php create mode 100644 core/vendor/kriswallsmith/assetic/src/Assetic/Filter/EmberPrecompileFilter.php create mode 100644 core/vendor/kriswallsmith/assetic/src/Assetic/Filter/RooleFilter.php create mode 100644 core/vendor/kriswallsmith/assetic/src/Assetic/Util/CssUtils.php create mode 100644 core/vendor/kriswallsmith/assetic/src/Assetic/Util/LessUtils.php delete mode 100644 core/vendor/kriswallsmith/assetic/src/Assetic/Util/PathUtils.php create mode 100644 core/vendor/kriswallsmith/assetic/src/Assetic/Util/VarUtils.php create mode 100644 core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageFunctionParenthesesTest.php create mode 100644 core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageFunctionParenthesesWhitespaceTest.php create mode 100644 core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodParenthesesTest.php create mode 100644 core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodParenthesesWhitespaceTest.php create mode 100644 core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsJson.php create mode 100644 core/vendor/phpunit/phpunit/Tests/Framework/Assert/FunctionsTest.php create mode 100644 core/vendor/phpunit/phpunit/Tests/Framework/TestFailureTest.php create mode 100644 core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/WinCacheClassLoader.php create mode 100644 core/vendor/symfony/debug/Symfony/Component/Debug/.gitignore create mode 100644 core/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md create mode 100644 core/vendor/symfony/debug/Symfony/Component/Debug/Debug.php create mode 100644 core/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php create mode 100644 core/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php create mode 100644 core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php create mode 100644 core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php create mode 100644 core/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php create mode 100644 core/vendor/symfony/debug/Symfony/Component/Debug/LICENSE create mode 100644 core/vendor/symfony/debug/Symfony/Component/Debug/README.md rename core/vendor/symfony/{http-kernel/Symfony/Component/HttpKernel/Tests/Debug => debug/Symfony/Component/Debug/Tests}/ErrorHandlerTest.php (96%) rename core/vendor/symfony/{http-kernel/Symfony/Component/HttpKernel => debug/Symfony/Component/Debug}/Tests/Exception/FlattenExceptionTest.php (98%) rename core/vendor/symfony/{http-kernel/Symfony/Component/HttpKernel/Tests/Debug => debug/Symfony/Component/Debug/Tests}/ExceptionHandlerTest.php (95%) create mode 100644 core/vendor/symfony/debug/Symfony/Component/Debug/composer.json create mode 100644 core/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist create mode 100644 core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/InstantiatorInterface.php create mode 100644 core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/RealServiceInstantiator.php create mode 100644 core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php create mode 100644 core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php create mode 100644 core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php create mode 100644 core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/LazyProxy/PhpDumper/NullDumperTest.php create mode 100644 core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php create mode 100644 core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTestCase.php create mode 100644 core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php rename core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/{DeprecationLoggerListener.php => ErrorsLoggerListener.php} (73%) create mode 100755 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php create mode 100644 core/vendor/symfony/process/Symfony/Component/Process/ProcessUtils.php create mode 100644 core/vendor/symfony/process/Symfony/Component/Process/Tests/NonStopableProcess.php create mode 100644 core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessUtilsTest.php create mode 100644 core/vendor/symfony/process/Symfony/Component/Process/Tests/SignalListener.php create mode 100644 core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouterTest.php create mode 100644 core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php create mode 100644 core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php rename core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/{Min.php => AbstractComparison.php} (52%) create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Currency.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CurrencyValidator.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualTo.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualToValidator.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Existence.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThan.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqualValidator.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanValidator.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Iban.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IbanValidator.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalTo.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalToValidator.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Isbn.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IsbnValidator.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Issn.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IssnValidator.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThan.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqual.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqualValidator.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanValidator.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Max.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MaxLength.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MaxLengthValidator.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MaxValidator.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MinLength.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MinLengthValidator.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MinValidator.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualTo.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualToValidator.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalTo.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalToValidator.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Optional.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Required.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/GraphWalker.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactoryAdapter.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactoryInterface.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ConstraintValidatorTest.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LocalizedTestCase.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MaxLengthValidatorTest.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MaxValidatorTest.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MinLengthValidatorTest.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MinValidatorTest.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php create mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/GraphWalkerTest.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorContextTest.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorFactoryTest.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorContext.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorContextInterface.php delete mode 100644 core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorFactory.php diff --git a/composer.json b/composer.json index 9b317c4580e0..f8b4473b0154 100644 --- a/composer.json +++ b/composer.json @@ -4,15 +4,15 @@ "type": "drupal-core", "license": "GPL-2.0+", "require": { - "symfony/class-loader": "2.2.*", - "symfony/dependency-injection": "2.2.*", - "symfony/event-dispatcher": "2.2.*", - "symfony/http-foundation": "2.2.*", - "symfony/http-kernel": "2.2.*", - "symfony/routing": "2.2.*", - "symfony/serializer": "2.2.*", - "symfony/validator": "2.2.*", - "symfony/yaml": "2.2.*", + "symfony/class-loader": "2.3.*", + "symfony/dependency-injection": "2.3.*", + "symfony/event-dispatcher": "2.3.*", + "symfony/http-foundation": "2.3.*", + "symfony/http-kernel": "2.3.*", + "symfony/routing": "2.3.*", + "symfony/serializer": "2.3.*", + "symfony/validator": "2.3.*", + "symfony/yaml": "2.3.*", "twig/twig": "1.12.*", "doctrine/common": "2.3.*", "guzzle/http": "3.1.*", diff --git a/composer.lock b/composer.lock index e8a696a72889..dea5f2458d95 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "8969a2b9cb8e5b12a6649cadfa010bab", + "hash": "e2836b171e18ace7a3f758875041815a", "packages": [ { "name": "doctrine/common", @@ -57,9 +57,9 @@ "email": "kontakt@beberlei.de" }, { - "name": "Johannes M. Schmitt", + "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", + "homepage": "http://jmsyst.com", "role": "Developer of wrapped JMSSerializerBundle" } ], @@ -325,21 +325,21 @@ }, { "name": "kriswallsmith/assetic", - "version": "v1.1.0-alpha4", + "version": "v1.1.1", "source": { "type": "git", "url": "https://github.com/kriswallsmith/assetic.git", - "reference": "v1.1.0-alpha4" + "reference": "v1.1.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/v1.1.0-alpha4", - "reference": "v1.1.0-alpha4", + "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/v1.1.1", + "reference": "v1.1.1", "shasum": "" }, "require": { "php": ">=5.3.1", - "symfony/process": ">=2.1.0,<2.3-dev" + "symfony/process": ">=2.1,<3.0" }, "require-dev": { "cssmin/cssmin": "*", @@ -349,9 +349,9 @@ "leafo/scssphp": "*", "leafo/scssphp-compass": "*", "mrclay/minify": "*", - "phpunit/phpunit": "3.7.*", + "phpunit/phpunit": ">=3.7,<4.0", "ptachoire/cssembed": "*", - "twig/twig": ">=1.6.0,<2.0" + "twig/twig": ">=1.6,<2.0" }, "suggest": { "leafo/lessphp": "Assetic provides the integration with the lessphp LESS compiler", @@ -392,20 +392,20 @@ "compression", "minification" ], - "time": "2013-02-24 17:22:20" + "time": "2013-06-01 22:13:43" }, { "name": "phpunit/php-code-coverage", - "version": "1.2.9", + "version": "1.2.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "1.2.9" + "reference": "1.2.11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1.2.9", - "reference": "1.2.9", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1.2.11", + "reference": "1.2.11", "shasum": "" }, "require": { @@ -414,6 +414,9 @@ "phpunit/php-text-template": ">=1.1.1@stable", "phpunit/php-token-stream": ">=1.1.3@stable" }, + "require-dev": { + "phpunit/phpunit": "3.7.*" + }, "suggest": { "ext-dom": "*", "ext-xdebug": ">=2.0.5" @@ -445,7 +448,7 @@ "testing", "xunit" ], - "time": "2013-02-26 18:55:56" + "time": "2013-05-23 18:23:24" }, { "name": "phpunit/php-file-iterator", @@ -627,16 +630,16 @@ }, { "name": "phpunit/phpunit", - "version": "3.7.19", + "version": "3.7.21", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3.7.19" + "reference": "3.7.21" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.19", - "reference": "3.7.19", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.21", + "reference": "3.7.21", "shasum": "" }, "require": { @@ -650,7 +653,7 @@ "phpunit/php-text-template": ">=1.1.1", "phpunit/php-timer": ">=1.0.2,<1.1.0", "phpunit/phpunit-mock-objects": ">=1.2.0,<1.3.0", - "symfony/yaml": ">=2.0.0,<2.3.0" + "symfony/yaml": ">=2.0,<3.0" }, "require-dev": { "pear-pear/pear": "1.9.4" @@ -697,7 +700,7 @@ "testing", "xunit" ], - "time": "2013-03-25 11:45:06" + "time": "2013-05-23 18:54:29" }, { "name": "phpunit/phpunit-mock-objects", @@ -788,24 +791,24 @@ }, { "name": "symfony-cmf/routing", - "version": "1.1.0-alpha1", + "version": "1.1.0-alpha2", "target-dir": "Symfony/Cmf/Component/Routing", "source": { "type": "git", "url": "https://github.com/symfony-cmf/Routing.git", - "reference": "1.1.0-alpha1" + "reference": "1.1.0-alpha2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/1.1.0-alpha1", - "reference": "1.1.0-alpha1", + "url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/1.1.0-alpha2", + "reference": "1.1.0-alpha2", "shasum": "" }, "require": { "php": ">=5.3.2", "psr/log": ">=1.0,<2.0", - "symfony/http-kernel": ">=2.2,<2.3-dev", - "symfony/routing": ">=2.2,<2.3-dev" + "symfony/http-kernel": ">=2.2,<2.4-dev", + "symfony/routing": ">=2.2,<2.4-dev" }, "suggest": { "symfony/http-foundation": "ChainRouter/DynamicRouter have optional support for Request instances, several enhancers require a Request instances, >=2.2,<2.3-dev" @@ -837,21 +840,21 @@ "database", "routing" ], - "time": "2013-05-07 06:30:59" + "time": "2013-05-28 19:50:20" }, { "name": "symfony/class-loader", - "version": "v2.2.1", + "version": "v2.3.1", "target-dir": "Symfony/Component/ClassLoader", "source": { "type": "git", "url": "https://github.com/symfony/ClassLoader.git", - "reference": "v2.2.1" + "reference": "v2.3.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/v2.3.1", + "reference": "v2.3.1", "shasum": "" }, "require": { @@ -863,7 +866,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -887,38 +890,95 @@ ], "description": "Symfony ClassLoader Component", "homepage": "http://symfony.com", - "time": "2013-03-19 08:32:26" + "time": "2013-05-24 17:54:44" + }, + { + "name": "symfony/debug", + "version": "v2.3.1", + "target-dir": "Symfony/Component/Debug", + "source": { + "type": "git", + "url": "https://github.com/symfony/Debug.git", + "reference": "v2.3.1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Debug/zipball/v2.3.1", + "reference": "v2.3.1", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/http-foundation": ">=2.1,<3.0", + "symfony/http-kernel": ">=2.1,<3.0" + }, + "suggest": { + "symfony/class-loader": "", + "symfony/http-foundation": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Debug\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "http://symfony.com", + "time": "2013-06-02 11:58:44" }, { "name": "symfony/dependency-injection", - "version": "v2.2.1", + "version": "v2.3.1", "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "v2.2.1" + "reference": "v2.3.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/v2.3.1", + "reference": "v2.3.1", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/config": ">=2.2,<2.3-dev", + "symfony/config": ">=2.2,<3.0", "symfony/yaml": ">=2.0,<3.0" }, "suggest": { - "symfony/config": "2.2.*", - "symfony/yaml": "2.2.*" + "symfony/config": "", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -942,21 +1002,21 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "http://symfony.com", - "time": "2013-03-23 07:49:54" + "time": "2013-06-05 09:51:05" }, { "name": "symfony/event-dispatcher", - "version": "v2.2.1", + "version": "v2.3.0", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "v2.2.1" + "reference": "v2.3.0-RC1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.3.0-RC1", + "reference": "v2.3.0-RC1", "shasum": "" }, "require": { @@ -966,13 +1026,13 @@ "symfony/dependency-injection": ">=2.0,<3.0" }, "suggest": { - "symfony/dependency-injection": "2.2.*", - "symfony/http-kernel": "2.2.*" + "symfony/dependency-injection": "", + "symfony/http-kernel": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -996,21 +1056,21 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2013-02-11 11:26:43" + "time": "2013-05-13 14:36:40" }, { "name": "symfony/http-foundation", - "version": "v2.2.1", + "version": "v2.3.1", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "v2.2.1" + "reference": "v2.3.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/v2.3.1", + "reference": "v2.3.1", "shasum": "" }, "require": { @@ -1019,7 +1079,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -1046,28 +1106,29 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "http://symfony.com", - "time": "2013-04-06 10:15:43" + "time": "2013-05-10 06:00:03" }, { "name": "symfony/http-kernel", - "version": "v2.2.1", + "version": "v2.3.0", "target-dir": "Symfony/Component/HttpKernel", "source": { "type": "git", "url": "https://github.com/symfony/HttpKernel.git", - "reference": "v2.2.1" + "reference": "v2.3.0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/v2.3.0", + "reference": "v2.3.0", "shasum": "" }, "require": { "php": ">=5.3.3", "psr/log": ">=1.0,<2.0", + "symfony/debug": ">=2.3,<3.0", "symfony/event-dispatcher": ">=2.1,<3.0", - "symfony/http-foundation": ">=2.2,<2.3-dev" + "symfony/http-foundation": ">=2.2,<3.0" }, "require-dev": { "symfony/browser-kit": "2.2.*", @@ -1077,21 +1138,21 @@ "symfony/dependency-injection": ">=2.0,<3.0", "symfony/finder": ">=2.0,<3.0", "symfony/process": ">=2.0,<3.0", - "symfony/routing": ">=2.2,<2.3-dev", - "symfony/stopwatch": ">=2.2,<2.3-dev" + "symfony/routing": ">=2.2,<3.0", + "symfony/stopwatch": ">=2.2,<3.0" }, "suggest": { - "symfony/browser-kit": "2.2.*", - "symfony/class-loader": "2.2.*", - "symfony/config": "2.2.*", - "symfony/console": "2.2.*", - "symfony/dependency-injection": "2.2.*", - "symfony/finder": "2.2.*" + "symfony/browser-kit": "", + "symfony/class-loader": "", + "symfony/config": "", + "symfony/console": "", + "symfony/dependency-injection": "", + "symfony/finder": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -1115,21 +1176,21 @@ ], "description": "Symfony HttpKernel Component", "homepage": "http://symfony.com", - "time": "2013-04-06 10:16:33" + "time": "2013-06-03 14:13:35" }, { "name": "symfony/process", - "version": "v2.2.1", + "version": "v2.3.1", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "v2.2.1" + "reference": "v2.3.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Process/zipball/v2.3.1", + "reference": "v2.3.1", "shasum": "" }, "require": { @@ -1138,7 +1199,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -1162,21 +1223,21 @@ ], "description": "Symfony Process Component", "homepage": "http://symfony.com", - "time": "2013-03-23 07:49:54" + "time": "2013-05-06 20:03:44" }, { "name": "symfony/routing", - "version": "v2.2.1", + "version": "v2.3.0", "target-dir": "Symfony/Component/Routing", "source": { "type": "git", "url": "https://github.com/symfony/Routing.git", - "reference": "v2.2.1" + "reference": "v2.3.0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Routing/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Routing/zipball/v2.3.0", + "reference": "v2.3.0", "shasum": "" }, "require": { @@ -1185,18 +1246,18 @@ "require-dev": { "doctrine/common": ">=2.2,<3.0", "psr/log": ">=1.0,<2.0", - "symfony/config": ">=2.2,<2.3-dev", + "symfony/config": ">=2.2,<3.0", "symfony/yaml": ">=2.0,<3.0" }, "suggest": { - "doctrine/common": "~2.2", - "symfony/config": "2.2.*", - "symfony/yaml": "2.2.*" + "doctrine/common": "", + "symfony/config": "", + "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -1220,21 +1281,21 @@ ], "description": "Symfony Routing Component", "homepage": "http://symfony.com", - "time": "2013-03-23 12:03:22" + "time": "2013-05-20 08:57:26" }, { "name": "symfony/serializer", - "version": "v2.2.1", + "version": "v2.3.1", "target-dir": "Symfony/Component/Serializer", "source": { "type": "git", "url": "https://github.com/symfony/Serializer.git", - "reference": "v2.2.1" + "reference": "v2.3.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Serializer/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Serializer/zipball/v2.3.1", + "reference": "v2.3.1", "shasum": "" }, "require": { @@ -1243,7 +1304,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -1267,38 +1328,38 @@ ], "description": "Symfony Serializer Component", "homepage": "http://symfony.com", - "time": "2013-03-06 21:43:23" + "time": "2013-05-10 18:12:13" }, { "name": "symfony/translation", - "version": "v2.2.1", + "version": "v2.3.0", "target-dir": "Symfony/Component/Translation", "source": { "type": "git", "url": "https://github.com/symfony/Translation.git", - "reference": "v2.2.1" + "reference": "v2.3.0-RC1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Translation/zipball/v2.3.0-RC1", + "reference": "v2.3.0-RC1", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/config": ">=2.0,<2.3-dev", + "symfony/config": ">=2.0,<3.0", "symfony/yaml": ">=2.2,<3.0" }, "suggest": { - "symfony/config": "2.2.*", - "symfony/yaml": "2.2.*" + "symfony/config": "", + "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -1322,21 +1383,21 @@ ], "description": "Symfony Translation Component", "homepage": "http://symfony.com", - "time": "2013-04-01 08:06:05" + "time": "2013-05-13 14:36:40" }, { "name": "symfony/validator", - "version": "v2.2.1", + "version": "v2.3.1", "target-dir": "Symfony/Component/Validator", "source": { "type": "git", "url": "https://github.com/symfony/Validator.git", - "reference": "v2.2.1" + "reference": "v2.3.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Validator/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Validator/zipball/v2.3.1", + "reference": "v2.3.1", "shasum": "" }, "require": { @@ -1344,22 +1405,22 @@ "symfony/translation": ">=2.0,<3.0" }, "require-dev": { - "symfony/config": ">=2.2,<2.3-dev", + "symfony/config": ">=2.2,<3.0", "symfony/http-foundation": ">=2.1,<3.0", - "symfony/locale": ">=2.0,<3.0", + "symfony/intl": ">=2.3,<3.0", "symfony/yaml": ">=2.0,<3.0" }, "suggest": { - "doctrine/common": "~2.2", - "symfony/config": "2.2.*", - "symfony/http-foundation": "2.2.*", - "symfony/locale": "2.2.*", - "symfony/yaml": "2.2.*" + "doctrine/common": "", + "symfony/config": "", + "symfony/http-foundation": "", + "symfony/intl": "", + "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -1383,21 +1444,21 @@ ], "description": "Symfony Validator Component", "homepage": "http://symfony.com", - "time": "2013-04-01 08:06:05" + "time": "2013-06-10 16:23:25" }, { "name": "symfony/yaml", - "version": "v2.2.1", + "version": "v2.3.0", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "v2.2.1" + "reference": "v2.3.0-RC1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.3.0-RC1", + "reference": "v2.3.0-RC1", "shasum": "" }, "require": { @@ -1406,7 +1467,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -1430,7 +1491,7 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2013-03-23 07:49:54" + "time": "2013-05-10 18:12:13" }, { "name": "twig/twig", diff --git a/core/vendor/autoload.php b/core/vendor/autoload.php index 9c5340f62335..ebc5b04c3cf6 100644 --- a/core/vendor/autoload.php +++ b/core/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInitc244582ae2d491644d70197d64a9670b::getLoader(); +return ComposerAutoloaderInitc269e792cec97d4c278bb968546f51b4::getLoader(); diff --git a/core/vendor/composer/ClassLoader.php b/core/vendor/composer/ClassLoader.php index 3679d464614c..ef9924516ae0 100644 --- a/core/vendor/composer/ClassLoader.php +++ b/core/vendor/composer/ClassLoader.php @@ -197,6 +197,7 @@ public function loadClass($class) */ public function findFile($class) { + // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 if ('\\' == $class[0]) { $class = substr($class, 1); } diff --git a/core/vendor/composer/autoload_classmap.php b/core/vendor/composer/autoload_classmap.php index 002677e1ffa8..fe65adea6b37 100644 --- a/core/vendor/composer/autoload_classmap.php +++ b/core/vendor/composer/autoload_classmap.php @@ -52,6 +52,7 @@ 'PHPUnit_Framework_Constraint_IsFalse' => $vendorDir . '/phpunit/phpunit/PHPUnit/Framework/Constraint/IsFalse.php', 'PHPUnit_Framework_Constraint_IsIdentical' => $vendorDir . '/phpunit/phpunit/PHPUnit/Framework/Constraint/IsIdentical.php', 'PHPUnit_Framework_Constraint_IsInstanceOf' => $vendorDir . '/phpunit/phpunit/PHPUnit/Framework/Constraint/IsInstanceOf.php', + 'PHPUnit_Framework_Constraint_IsJson' => $vendorDir . '/phpunit/phpunit/PHPUnit/Framework/Constraint/IsJson.php', 'PHPUnit_Framework_Constraint_IsNull' => $vendorDir . '/phpunit/phpunit/PHPUnit/Framework/Constraint/IsNull.php', 'PHPUnit_Framework_Constraint_IsTrue' => $vendorDir . '/phpunit/phpunit/PHPUnit/Framework/Constraint/IsTrue.php', 'PHPUnit_Framework_Constraint_IsType' => $vendorDir . '/phpunit/phpunit/PHPUnit/Framework/Constraint/IsType.php', diff --git a/core/vendor/composer/autoload_namespaces.php b/core/vendor/composer/autoload_namespaces.php index c2c383ac30d2..3385df1d1058 100644 --- a/core/vendor/composer/autoload_namespaces.php +++ b/core/vendor/composer/autoload_namespaces.php @@ -17,6 +17,7 @@ 'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'), 'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'), 'Symfony\\Component\\DependencyInjection\\' => array($vendorDir . '/symfony/dependency-injection'), + 'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'), 'Symfony\\Component\\ClassLoader\\' => array($vendorDir . '/symfony/class-loader'), 'Symfony\\Cmf\\Component\\Routing' => array($vendorDir . '/symfony-cmf/routing'), 'Psr\\Log\\' => array($vendorDir . '/psr/log'), diff --git a/core/vendor/composer/autoload_real.php b/core/vendor/composer/autoload_real.php index 5271995cd718..843e1e8c0b80 100644 --- a/core/vendor/composer/autoload_real.php +++ b/core/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php generated by Composer -class ComposerAutoloaderInitc244582ae2d491644d70197d64a9670b +class ComposerAutoloaderInitc269e792cec97d4c278bb968546f51b4 { private static $loader; @@ -19,9 +19,9 @@ public static function getLoader() return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitc244582ae2d491644d70197d64a9670b', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitc269e792cec97d4c278bb968546f51b4', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInitc244582ae2d491644d70197d64a9670b', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitc269e792cec97d4c278bb968546f51b4', 'loadClassLoader')); $vendorDir = dirname(__DIR__); $baseDir = dirname(dirname($vendorDir)); diff --git a/core/vendor/composer/installed.json b/core/vendor/composer/installed.json index fe8a28729458..7ee26800b332 100644 --- a/core/vendor/composer/installed.json +++ b/core/vendor/composer/installed.json @@ -54,9 +54,9 @@ "email": "kontakt@beberlei.de" }, { - "name": "Johannes M. Schmitt", + "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", + "homepage": "http://jmsyst.com", "role": "Developer of wrapped JMSSerializerBundle" } ], @@ -70,6 +70,114 @@ "spl" ] }, + { + "name": "easyrdf/easyrdf", + "version": "0.8.0-beta.1", + "version_normalized": "0.8.0.0-beta1", + "source": { + "type": "git", + "url": "git://github.com/njh/easyrdf.git", + "reference": "0.8.0-beta.1" + }, + "dist": { + "type": "zip", + "url": "https://github.com/njh/easyrdf/archive/0.8.0-beta.1.zip", + "reference": "0.8.0-beta.1", + "shasum": "" + }, + "require": { + "php": ">=5.2.8" + }, + "replace": { + "njh/easyrdf": "self.version" + }, + "require-dev": { + "phpunit/phpunit": ">=3.5.15", + "sami/sami": "dev-master", + "squizlabs/php_codesniffer": ">=1.4.3" + }, + "time": "2013-01-18 15:54:28", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "EasyRdf_": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nicholas Humfrey", + "email": "njh@aelius.com", + "homepage": "http://www.aelius.com/njh/", + "role": "Developer" + } + ], + "description": "EasyRdf is a PHP library designed to make it easy to consume and produce RDF.", + "homepage": "http://www.easyrdf.org/", + "keywords": [ + "Linked Data", + "RDF", + "Semantic Web", + "Turtle", + "rdfa" + ] + }, + { + "name": "symfony/class-loader", + "version": "v2.3.1", + "version_normalized": "2.3.1.0", + "target-dir": "Symfony/Component/ClassLoader", + "source": { + "type": "git", + "url": "https://github.com/symfony/ClassLoader.git", + "reference": "v2.3.1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/v2.3.1", + "reference": "v2.3.1", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/finder": ">=2.0,<3.0" + }, + "time": "2013-05-24 17:54:44", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\ClassLoader\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony ClassLoader Component", + "homepage": "http://symfony.com" + }, { "name": "psr/log", "version": "1.0.0", @@ -161,30 +269,88 @@ "templating" ] }, + { + "name": "symfony/debug", + "version": "v2.3.1", + "version_normalized": "2.3.1.0", + "target-dir": "Symfony/Component/Debug", + "source": { + "type": "git", + "url": "https://github.com/symfony/Debug.git", + "reference": "v2.3.1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Debug/zipball/v2.3.1", + "reference": "v2.3.1", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/http-foundation": ">=2.1,<3.0", + "symfony/http-kernel": ">=2.1,<3.0" + }, + "suggest": { + "symfony/class-loader": "", + "symfony/http-foundation": "", + "symfony/http-kernel": "" + }, + "time": "2013-06-02 11:58:44", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Debug\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "http://symfony.com" + }, { "name": "symfony/http-foundation", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.3.1", + "version_normalized": "2.3.1.0", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "v2.2.1" + "reference": "v2.3.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/v2.3.1", + "reference": "v2.3.1", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2013-04-06 10:15:43", + "time": "2013-05-10 06:00:03", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "installation-source": "dist", @@ -215,18 +381,18 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.3.0", + "version_normalized": "2.3.0.0", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "v2.2.1" + "reference": "v2.3.0-RC1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.3.0-RC1", + "reference": "v2.3.0-RC1", "shasum": "" }, "require": { @@ -236,14 +402,14 @@ "symfony/dependency-injection": ">=2.0,<3.0" }, "suggest": { - "symfony/dependency-injection": "2.2.*", - "symfony/http-kernel": "2.2.*" + "symfony/dependency-injection": "", + "symfony/http-kernel": "" }, - "time": "2013-02-11 11:26:43", + "time": "2013-05-13 14:36:40", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "installation-source": "dist", @@ -271,25 +437,26 @@ }, { "name": "symfony/http-kernel", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.3.0", + "version_normalized": "2.3.0.0", "target-dir": "Symfony/Component/HttpKernel", "source": { "type": "git", "url": "https://github.com/symfony/HttpKernel.git", - "reference": "v2.2.1" + "reference": "v2.3.0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/v2.3.0", + "reference": "v2.3.0", "shasum": "" }, "require": { "php": ">=5.3.3", "psr/log": ">=1.0,<2.0", + "symfony/debug": ">=2.3,<3.0", "symfony/event-dispatcher": ">=2.1,<3.0", - "symfony/http-foundation": ">=2.2,<2.3-dev" + "symfony/http-foundation": ">=2.2,<3.0" }, "require-dev": { "symfony/browser-kit": "2.2.*", @@ -299,22 +466,22 @@ "symfony/dependency-injection": ">=2.0,<3.0", "symfony/finder": ">=2.0,<3.0", "symfony/process": ">=2.0,<3.0", - "symfony/routing": ">=2.2,<2.3-dev", - "symfony/stopwatch": ">=2.2,<2.3-dev" + "symfony/routing": ">=2.2,<3.0", + "symfony/stopwatch": ">=2.2,<3.0" }, "suggest": { - "symfony/browser-kit": "2.2.*", - "symfony/class-loader": "2.2.*", - "symfony/config": "2.2.*", - "symfony/console": "2.2.*", - "symfony/dependency-injection": "2.2.*", - "symfony/finder": "2.2.*" - }, - "time": "2013-04-06 10:16:33", + "symfony/browser-kit": "", + "symfony/class-loader": "", + "symfony/config": "", + "symfony/console": "", + "symfony/dependency-injection": "", + "symfony/finder": "" + }, + "time": "2013-06-03 14:13:35", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "installation-source": "dist", @@ -342,18 +509,18 @@ }, { "name": "symfony/routing", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.3.0", + "version_normalized": "2.3.0.0", "target-dir": "Symfony/Component/Routing", "source": { "type": "git", "url": "https://github.com/symfony/Routing.git", - "reference": "v2.2.1" + "reference": "v2.3.0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Routing/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Routing/zipball/v2.3.0", + "reference": "v2.3.0", "shasum": "" }, "require": { @@ -362,19 +529,19 @@ "require-dev": { "doctrine/common": ">=2.2,<3.0", "psr/log": ">=1.0,<2.0", - "symfony/config": ">=2.2,<2.3-dev", + "symfony/config": ">=2.2,<3.0", "symfony/yaml": ">=2.0,<3.0" }, "suggest": { - "doctrine/common": "~2.2", - "symfony/config": "2.2.*", - "symfony/yaml": "2.2.*" + "doctrine/common": "", + "symfony/config": "", + "symfony/yaml": "" }, - "time": "2013-03-23 12:03:22", + "time": "2013-05-20 08:57:26", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "installation-source": "dist", @@ -401,94 +568,41 @@ "homepage": "http://symfony.com" }, { - "name": "easyrdf/easyrdf", - "version": "0.8.0-beta.1", - "version_normalized": "0.8.0.0-beta1", - "source": { - "type": "git", - "url": "git://github.com/njh/easyrdf.git", - "reference": "0.8.0-beta.1" - }, - "dist": { - "type": "zip", - "url": "https://github.com/njh/easyrdf/archive/0.8.0-beta.1.zip", - "reference": "0.8.0-beta.1", - "shasum": "" - }, - "require": { - "php": ">=5.2.8" - }, - "replace": { - "njh/easyrdf": "self.version" - }, - "require-dev": { - "phpunit/phpunit": ">=3.5.15", - "sami/sami": "dev-master", - "squizlabs/php_codesniffer": ">=1.4.3" - }, - "time": "2013-01-18 15:54:28", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "EasyRdf_": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Nicholas Humfrey", - "email": "njh@aelius.com", - "homepage": "http://www.aelius.com/njh/", - "role": "Developer" - } - ], - "description": "EasyRdf is a PHP library designed to make it easy to consume and produce RDF.", - "homepage": "http://www.easyrdf.org/", - "keywords": [ - "Linked Data", - "RDF", - "Semantic Web", - "Turtle", - "rdfa" - ] - }, - { - "name": "symfony/class-loader", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", - "target-dir": "Symfony/Component/ClassLoader", + "name": "symfony-cmf/routing", + "version": "1.1.0-alpha2", + "version_normalized": "1.1.0.0-alpha2", + "target-dir": "Symfony/Cmf/Component/Routing", "source": { "type": "git", - "url": "https://github.com/symfony/ClassLoader.git", - "reference": "v2.2.1" + "url": "https://github.com/symfony-cmf/Routing.git", + "reference": "1.1.0-alpha2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/1.1.0-alpha2", + "reference": "1.1.0-alpha2", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.2", + "psr/log": ">=1.0,<2.0", + "symfony/http-kernel": ">=2.2,<2.4-dev", + "symfony/routing": ">=2.2,<2.4-dev" }, - "require-dev": { - "symfony/finder": ">=2.0,<3.0" + "suggest": { + "symfony/http-foundation": "ChainRouter/DynamicRouter have optional support for Request instances, several enhancers require a Request instances, >=2.2,<2.3-dev" }, - "time": "2013-03-19 08:32:26", + "time": "2013-05-28 19:50:20", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "1.1-dev" } }, "installation-source": "dist", "autoload": { "psr-0": { - "Symfony\\Component\\ClassLoader\\": "" + "Symfony\\Cmf\\Component\\Routing": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -497,49 +611,50 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Symfony CMF Community", + "homepage": "https://github.com/symfony-cmf/Routing/contributors" } ], - "description": "Symfony ClassLoader Component", - "homepage": "http://symfony.com" + "description": "Extends the Symfony2 routing component for dynamic routes and chaining several routers", + "homepage": "http://cmf.symfony.com", + "keywords": [ + "database", + "routing" + ] }, { "name": "symfony/dependency-injection", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.3.1", + "version_normalized": "2.3.1.0", "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "v2.2.1" + "reference": "v2.3.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/v2.3.1", + "reference": "v2.3.1", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/config": ">=2.2,<2.3-dev", + "symfony/config": ">=2.2,<3.0", "symfony/yaml": ">=2.0,<3.0" }, "suggest": { - "symfony/config": "2.2.*", - "symfony/yaml": "2.2.*" + "symfony/config": "", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" }, - "time": "2013-03-23 07:49:54", + "time": "2013-06-05 09:51:05", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "installation-source": "dist", @@ -567,28 +682,28 @@ }, { "name": "symfony/serializer", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.3.1", + "version_normalized": "2.3.1.0", "target-dir": "Symfony/Component/Serializer", "source": { "type": "git", "url": "https://github.com/symfony/Serializer.git", - "reference": "v2.2.1" + "reference": "v2.3.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Serializer/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Serializer/zipball/v2.3.1", + "reference": "v2.3.1", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2013-03-06 21:43:23", + "time": "2013-05-10 18:12:13", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "installation-source": "dist", @@ -616,36 +731,36 @@ }, { "name": "symfony/translation", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.3.0", + "version_normalized": "2.3.0.0", "target-dir": "Symfony/Component/Translation", "source": { "type": "git", "url": "https://github.com/symfony/Translation.git", - "reference": "v2.2.1" + "reference": "v2.3.0-RC1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Translation/zipball/v2.3.0-RC1", + "reference": "v2.3.0-RC1", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/config": ">=2.0,<2.3-dev", + "symfony/config": ">=2.0,<3.0", "symfony/yaml": ">=2.2,<3.0" }, "suggest": { - "symfony/config": "2.2.*", - "symfony/yaml": "2.2.*" + "symfony/config": "", + "symfony/yaml": "" }, - "time": "2013-04-01 08:06:05", + "time": "2013-05-13 14:36:40", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "installation-source": "dist", @@ -673,18 +788,18 @@ }, { "name": "symfony/validator", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.3.1", + "version_normalized": "2.3.1.0", "target-dir": "Symfony/Component/Validator", "source": { "type": "git", "url": "https://github.com/symfony/Validator.git", - "reference": "v2.2.1" + "reference": "v2.3.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Validator/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Validator/zipball/v2.3.1", + "reference": "v2.3.1", "shasum": "" }, "require": { @@ -692,23 +807,23 @@ "symfony/translation": ">=2.0,<3.0" }, "require-dev": { - "symfony/config": ">=2.2,<2.3-dev", + "symfony/config": ">=2.2,<3.0", "symfony/http-foundation": ">=2.1,<3.0", - "symfony/locale": ">=2.0,<3.0", + "symfony/intl": ">=2.3,<3.0", "symfony/yaml": ">=2.0,<3.0" }, "suggest": { - "doctrine/common": "~2.2", - "symfony/config": "2.2.*", - "symfony/http-foundation": "2.2.*", - "symfony/locale": "2.2.*", - "symfony/yaml": "2.2.*" + "doctrine/common": "", + "symfony/config": "", + "symfony/http-foundation": "", + "symfony/intl": "", + "symfony/yaml": "" }, - "time": "2013-04-01 08:06:05", + "time": "2013-06-10 16:23:25", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "installation-source": "dist", @@ -939,28 +1054,28 @@ }, { "name": "symfony/process", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.3.1", + "version_normalized": "2.3.1.0", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "v2.2.1" + "reference": "v2.3.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Process/zipball/v2.3.1", + "reference": "v2.3.1", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2013-03-23 07:49:54", + "time": "2013-05-06 20:03:44", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "installation-source": "dist", @@ -988,22 +1103,22 @@ }, { "name": "kriswallsmith/assetic", - "version": "v1.1.0-alpha4", - "version_normalized": "1.1.0.0-alpha4", + "version": "v1.1.1", + "version_normalized": "1.1.1.0", "source": { "type": "git", "url": "https://github.com/kriswallsmith/assetic.git", - "reference": "v1.1.0-alpha4" + "reference": "v1.1.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/v1.1.0-alpha4", - "reference": "v1.1.0-alpha4", + "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/v1.1.1", + "reference": "v1.1.1", "shasum": "" }, "require": { "php": ">=5.3.1", - "symfony/process": ">=2.1.0,<2.3-dev" + "symfony/process": ">=2.1,<3.0" }, "require-dev": { "cssmin/cssmin": "*", @@ -1013,9 +1128,9 @@ "leafo/scssphp": "*", "leafo/scssphp-compass": "*", "mrclay/minify": "*", - "phpunit/phpunit": "3.7.*", + "phpunit/phpunit": ">=3.7,<4.0", "ptachoire/cssembed": "*", - "twig/twig": ">=1.6.0,<2.0" + "twig/twig": ">=1.6,<2.0" }, "suggest": { "leafo/lessphp": "Assetic provides the integration with the lessphp LESS compiler", @@ -1024,7 +1139,7 @@ "ptachoire/cssembed": "Assetic provides the integration with phpcssembed to embed data uris", "twig/twig": "Assetic provides the integration with the Twig templating engine" }, - "time": "2013-02-24 17:22:20", + "time": "2013-06-01 22:13:43", "type": "library", "extra": { "branch-alias": { @@ -1061,28 +1176,28 @@ }, { "name": "symfony/yaml", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.3.0", + "version_normalized": "2.3.0.0", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "v2.2.1" + "reference": "v2.3.0-RC1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.3.0-RC1", + "reference": "v2.3.0-RC1", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2013-03-23 07:49:54", + "time": "2013-05-10 18:12:13", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "installation-source": "dist", @@ -1347,17 +1462,17 @@ }, { "name": "phpunit/php-code-coverage", - "version": "1.2.9", - "version_normalized": "1.2.9.0", + "version": "1.2.11", + "version_normalized": "1.2.11.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "1.2.9" + "reference": "1.2.11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1.2.9", - "reference": "1.2.9", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1.2.11", + "reference": "1.2.11", "shasum": "" }, "require": { @@ -1366,11 +1481,14 @@ "phpunit/php-text-template": ">=1.1.1@stable", "phpunit/php-token-stream": ">=1.1.3@stable" }, + "require-dev": { + "phpunit/phpunit": "3.7.*" + }, "suggest": { "ext-dom": "*", "ext-xdebug": ">=2.0.5" }, - "time": "2013-02-26 18:55:56", + "time": "2013-05-23 18:23:24", "type": "library", "installation-source": "dist", "autoload": { @@ -1402,17 +1520,17 @@ }, { "name": "phpunit/phpunit", - "version": "3.7.19", - "version_normalized": "3.7.19.0", + "version": "3.7.21", + "version_normalized": "3.7.21.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3.7.19" + "reference": "3.7.21" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.19", - "reference": "3.7.19", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.21", + "reference": "3.7.21", "shasum": "" }, "require": { @@ -1426,7 +1544,7 @@ "phpunit/php-text-template": ">=1.1.1", "phpunit/php-timer": ">=1.0.2,<1.1.0", "phpunit/phpunit-mock-objects": ">=1.2.0,<1.3.0", - "symfony/yaml": ">=2.0.0,<2.3.0" + "symfony/yaml": ">=2.0,<3.0" }, "require-dev": { "pear-pear/pear": "1.9.4" @@ -1437,7 +1555,7 @@ "ext-tokenizer": "*", "phpunit/php-invoker": ">=1.1.0,<1.2.0" }, - "time": "2013-03-25 11:45:06", + "time": "2013-05-23 18:54:29", "bin": [ "composer/bin/phpunit" ], @@ -1475,60 +1593,5 @@ "testing", "xunit" ] - }, - { - "name": "symfony-cmf/routing", - "version": "1.1.0-alpha1", - "version_normalized": "1.1.0.0-alpha1", - "target-dir": "Symfony/Cmf/Component/Routing", - "source": { - "type": "git", - "url": "https://github.com/symfony-cmf/Routing.git", - "reference": "1.1.0-alpha1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/1.1.0-alpha1", - "reference": "1.1.0-alpha1", - "shasum": "" - }, - "require": { - "php": ">=5.3.2", - "psr/log": ">=1.0,<2.0", - "symfony/http-kernel": ">=2.2,<2.3-dev", - "symfony/routing": ">=2.2,<2.3-dev" - }, - "suggest": { - "symfony/http-foundation": "ChainRouter/DynamicRouter have optional support for Request instances, several enhancers require a Request instances, >=2.2,<2.3-dev" - }, - "time": "2013-05-07 06:30:59", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Cmf\\Component\\Routing": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony CMF Community", - "homepage": "https://github.com/symfony-cmf/Routing/contributors" - } - ], - "description": "Extends the Symfony2 routing component for dynamic routes and chaining several routers", - "homepage": "http://cmf.symfony.com", - "keywords": [ - "database", - "routing" - ] } ] diff --git a/core/vendor/kriswallsmith/assetic/CHANGELOG-1.1.md b/core/vendor/kriswallsmith/assetic/CHANGELOG-1.1.md old mode 100755 new mode 100644 index 960bca74a2b2..a5a86405f667 --- a/core/vendor/kriswallsmith/assetic/CHANGELOG-1.1.md +++ b/core/vendor/kriswallsmith/assetic/CHANGELOG-1.1.md @@ -1,6 +1,21 @@ -1.1.0 ------ +1.1.1 (June 1, 2013) +-------------------- + * Fixed cloning of asset collections + * Fixed environment var inheritance + * Replaced `AssetWriter::getCombinations()` for BC, even though we don't use it + * Added support for `@import-once` to Less filters + +1.1.0 (May 15, 2013) +-------------------- + + * Added LazyAssetManager::getLastModified() for determining "deep" mtime + * Added DartFilter + * Added EmberPrecompile + * Added GssFilter + * Added PhpCssEmbedFilter + * Added RooleFilter + * Added TypeScriptFilter * Added the possibility to configure additional load paths for less and lessphp * Added the UglifyCssFilter * Fixed the handling of directories in the GlobAsset. #256 diff --git a/core/vendor/kriswallsmith/assetic/Gemfile b/core/vendor/kriswallsmith/assetic/Gemfile new file mode 100644 index 000000000000..1c532499a23d --- /dev/null +++ b/core/vendor/kriswallsmith/assetic/Gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gem "sprockets", "~> 1.0.0" +gem "sass" +gem "compass" diff --git a/core/vendor/kriswallsmith/assetic/README.md b/core/vendor/kriswallsmith/assetic/README.md index c9308c05dcb6..a6e56641da97 100644 --- a/core/vendor/kriswallsmith/assetic/README.md +++ b/core/vendor/kriswallsmith/assetic/README.md @@ -79,6 +79,7 @@ The core provides the following filters in the `Assetic\Filter` namespace: * `CssMinFilter`: minifies CSS * `CssRewriteFilter`: fixes relative URLs in CSS assets when moving to a new URL * `DartFilter`: compiles Javascript using dart2js + * `EmberPrecompileFilter`: precompiles Handlebars templates into Javascript for use in the Ember.js framework * `GoogleClosure\CompilerApiFilter`: compiles Javascript using the Google Closure Compiler API * `GoogleClosure\CompilerJarFilter`: compiles Javascript using the Google Closure Compiler JAR * `GssFilter`: compliles CSS using the Google Closure Stylesheets Compiler diff --git a/core/vendor/kriswallsmith/assetic/composer.json b/core/vendor/kriswallsmith/assetic/composer.json index 7e15e91f39e2..a9e2091da9fc 100644 --- a/core/vendor/kriswallsmith/assetic/composer.json +++ b/core/vendor/kriswallsmith/assetic/composer.json @@ -15,11 +15,11 @@ ], "require": { "php": ">=5.3.1", - "symfony/process": ">=2.1.0,<2.3-dev" + "symfony/process": "~2.1" }, "require-dev": { - "phpunit/phpunit": "3.7.*", - "twig/twig": ">=1.6.0,<2.0", + "phpunit/phpunit": "~3.7", + "twig/twig": "~1.6", "leafo/lessphp": "*", "leafo/scssphp": "*", "ptachoire/cssembed": "*", @@ -30,7 +30,6 @@ "kamicane/packager": "*", "joliclic/javascript-packer": "*" }, - "minimum-stability": "dev", "suggest": { "twig/twig": "Assetic provides the integration with the Twig templating engine", "leafo/lessphp": "Assetic provides the integration with the lessphp LESS compiler", @@ -60,15 +59,6 @@ "autoload": { "classmap": [ "cssmin-v3.0.1.php" ] } } }, - { - "type": "package", - "package": { - "name": "mrclay/minify", - "version": "2.1.5", - "dist": { "url": "http://minify.googlecode.com/files/minify-2.1.5.zip", "type": "zip" }, - "autoload": { "classmap": [ "min/lib/" ] } - } - }, { "type": "package", "package": { diff --git a/core/vendor/kriswallsmith/assetic/package.json b/core/vendor/kriswallsmith/assetic/package.json new file mode 100644 index 000000000000..c5f534f33840 --- /dev/null +++ b/core/vendor/kriswallsmith/assetic/package.json @@ -0,0 +1,12 @@ +{ + "devDependencies": { + "uglifycss": "*", + "coffee-script": "*", + "stylus": "*", + "ember-precompile": "*", + "typescript": "*", + "less": "*", + "handlebars": "*", + "uglify-js": "*" + } +} diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCollection.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCollection.php index 932877880637..6cfa3e8612de 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCollection.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCollection.php @@ -54,6 +54,12 @@ public function __construct($assets = array(), $filters = array(), $sourceRoot = $this->values = array(); } + public function __clone() + { + $this->filters = clone $this->filters; + $this->clones = new \SplObjectStorage(); + } + public function all() { return $this->assets; diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/FileAsset.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/FileAsset.php index 00870b043061..7a7e1132b087 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/FileAsset.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/FileAsset.php @@ -11,8 +11,8 @@ namespace Assetic\Asset; -use Assetic\Util\PathUtils; use Assetic\Filter\FilterInterface; +use Assetic\Util\VarUtils; /** * Represents an asset loaded from a file. @@ -56,7 +56,7 @@ public function __construct($source, $filters = array(), $sourceRoot = null, $so public function load(FilterInterface $additionalFilter = null) { - $source = PathUtils::resolvePath($this->source, $this->getVars(), $this->getValues()); + $source = VarUtils::resolve($this->source, $this->getVars(), $this->getValues()); if (!is_file($source)) { throw new \RuntimeException(sprintf('The source file "%s" does not exist.', $source)); @@ -67,7 +67,7 @@ public function load(FilterInterface $additionalFilter = null) public function getLastModified() { - $source = PathUtils::resolvePath($this->source, $this->getVars(), $this->getValues()); + $source = VarUtils::resolve($this->source, $this->getVars(), $this->getValues()); if (!is_file($source)) { throw new \RuntimeException(sprintf('The source file "%s" does not exist.', $source)); diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/GlobAsset.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/GlobAsset.php index daf6f5228d5f..f6c32ab775b8 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/GlobAsset.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/GlobAsset.php @@ -11,9 +11,8 @@ namespace Assetic\Asset; -use Assetic\Util\PathUtils; - use Assetic\Filter\FilterInterface; +use Assetic\Util\VarUtils; /** * A collection of assets loaded by glob. @@ -98,7 +97,7 @@ public function setValues(array $values) private function initialize() { foreach ($this->globs as $glob) { - $glob = PathUtils::resolvePath($glob, $this->getVars(), $this->getValues()); + $glob = VarUtils::resolve($glob, $this->getVars(), $this->getValues()); if (false !== $paths = glob($glob)) { foreach ($paths as $path) { diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/HttpAsset.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/HttpAsset.php index ef0d58c0389c..eea2350167f3 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/HttpAsset.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/HttpAsset.php @@ -11,9 +11,8 @@ namespace Assetic\Asset; -use Assetic\Util\PathUtils; - use Assetic\Filter\FilterInterface; +use Assetic\Util\VarUtils; /** * Represents an asset loaded via an HTTP request. @@ -54,13 +53,11 @@ public function __construct($sourceUrl, $filters = array(), $ignoreErrors = fals public function load(FilterInterface $additionalFilter = null) { - if (false === $content = @file_get_contents(PathUtils::resolvePath( - $this->sourceUrl, $this->getVars(), $this->getValues())) - ) { - if ($this->ignoreErrors) { - return; - } + $content = @file_get_contents( + VarUtils::resolve($this->sourceUrl, $this->getVars(), $this->getValues()) + ); + if (false === $content && !$this->ignoreErrors) { throw new \RuntimeException(sprintf('Unable to load asset from URL "%s"', $this->sourceUrl)); } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/AssetManager.php b/core/vendor/kriswallsmith/assetic/src/Assetic/AssetManager.php index 57d6d7107aa0..a55cd2ed917a 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/AssetManager.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/AssetManager.php @@ -58,7 +58,7 @@ public function has($name) * @param string $name The asset name * @param AssetInterface $asset The asset * - * @throws \InvalidArgumentException If tthe asset name is invalid + * @throws \InvalidArgumentException If the asset name is invalid */ public function set($name, AssetInterface $asset) { @@ -78,4 +78,12 @@ public function getNames() { return array_keys($this->assets); } + + /** + * Clears all assets. + */ + public function clear() + { + $this->assets = array(); + } } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/AssetWriter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/AssetWriter.php index f2c627fc8cb8..bbace99fcff0 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/AssetWriter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/AssetWriter.php @@ -11,9 +11,8 @@ namespace Assetic; -use Assetic\Util\PathUtils; - use Assetic\Asset\AssetInterface; +use Assetic\Util\VarUtils; /** * Writes assets to the filesystem. @@ -24,20 +23,20 @@ class AssetWriter { private $dir; - private $varValues; + private $values; /** * Constructor. * - * @param string $dir The base web directory - * @param array $varValues + * @param string $dir The base web directory + * @param array $values Variable values * * @throws \InvalidArgumentException if a variable value is not a string */ - public function __construct($dir, array $varValues = array()) + public function __construct($dir, array $values = array()) { - foreach ($varValues as $var => $values) { - foreach ($values as $value) { + foreach ($values as $var => $vals) { + foreach ($vals as $value) { if (!is_string($value)) { throw new \InvalidArgumentException(sprintf('All variable values must be strings, but got %s for variable "%s".', json_encode($value), $var)); } @@ -45,7 +44,7 @@ public function __construct($dir, array $varValues = array()) } $this->dir = $dir; - $this->varValues = $varValues; + $this->values = $values; } public function writeManagerAssets(AssetManager $am) @@ -57,46 +56,20 @@ public function writeManagerAssets(AssetManager $am) public function writeAsset(AssetInterface $asset) { - foreach ($this->getCombinations($asset->getVars()) as $combination) { + foreach (VarUtils::getCombinations($asset->getVars(), $this->values) as $combination) { $asset->setValues($combination); - static::write($this->dir.'/'.PathUtils::resolvePath( - $asset->getTargetPath(), $asset->getVars(), $asset->getValues()), - $asset->dump()); + static::write( + $this->dir.'/'.VarUtils::resolve( + $asset->getTargetPath(), + $asset->getVars(), + $asset->getValues() + ), + $asset->dump() + ); } } - private function getCombinations(array $vars) - { - if (!$vars) { - return array(array()); - } - - $combinations = array(); - $nbValues = array(); - foreach ($this->varValues as $var => $values) { - if (!in_array($var, $vars, true)) { - continue; - } - - $nbValues[$var] = count($values); - } - - for ($i=array_product($nbValues),$c=$i*2; $i<$c; $i++) { - $k = $i; - $combination = array(); - - foreach ($vars as $var) { - $combination[$var] = $this->varValues[$var][$k % $nbValues[$var]]; - $k = intval($k/$nbValues[$var]); - } - - $combinations[] = $combination; - } - - return $combinations; - } - protected static function write($path, $contents) { if (!is_dir($dir = dirname($path)) && false === @mkdir($dir, 0777, true)) { @@ -107,4 +80,15 @@ protected static function write($path, $contents) throw new \RuntimeException('Unable to write file '.$path); } } + + /** + * Not used. + * + * This method is provided for backward compatibility with certain versions + * of AsseticBundle. + */ + private function getCombinations(array $vars) + { + return VarUtils::getCombinations($vars, $this->values); + } } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Extension/Twig/AsseticExtension.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Extension/Twig/AsseticExtension.php index 575eeeb8b830..a63bc9e6d4d1 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Extension/Twig/AsseticExtension.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Extension/Twig/AsseticExtension.php @@ -11,8 +11,8 @@ namespace Assetic\Extension\Twig; -use Assetic\ValueSupplierInterface; use Assetic\Factory\AssetFactory; +use Assetic\ValueSupplierInterface; class AsseticExtension extends \Twig_Extension { diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/LazyAssetManager.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/LazyAssetManager.php index 922a65d5fa0f..5f8fe3f9b87c 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/LazyAssetManager.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/LazyAssetManager.php @@ -11,9 +11,11 @@ namespace Assetic\Factory; +use Assetic\Asset\AssetInterface; use Assetic\AssetManager; use Assetic\Factory\Loader\FormulaLoaderInterface; use Assetic\Factory\Resource\ResourceInterface; +use Assetic\Filter\DependencyExtractorInterface; /** * A lazy asset manager is a composition of a factory and many formula loaders. @@ -201,4 +203,40 @@ public function isDebug() { return $this->factory->isDebug(); } + + public function getLastModified(AssetInterface $asset) + { + $mtime = $asset->getLastModified(); + if (!$filters = $asset->getFilters()) { + return $mtime; + } + + // prepare load path + $sourceRoot = $asset->getSourceRoot(); + $sourcePath = $asset->getSourcePath(); + $loadPath = $sourceRoot && $sourcePath ? dirname($sourceRoot.'/'.$sourcePath) : null; + + $prevFilters = array(); + foreach ($filters as $filter) { + $prevFilters[] = $filter; + + if (!$filter instanceof DependencyExtractorInterface) { + continue; + } + + // extract children from asset after running all preceeding filters + $clone = clone $asset; + $clone->clearFilters(); + foreach (array_slice($prevFilters, 0, -1) as $prevFilter) { + $clone->ensureFilter($prevFilter); + } + $clone->load(); + + foreach ($filter->getChildren($this->factory, $clone->getContent(), $loadPath) as $child) { + $mtime = max($mtime, $this->getLastModified($child)); + } + } + + return $mtime; + } } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/Worker/CacheBustingWorker.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/Worker/CacheBustingWorker.php index aac8f884e438..8eaaee6a8995 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/Worker/CacheBustingWorker.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/Worker/CacheBustingWorker.php @@ -11,7 +11,9 @@ namespace Assetic\Factory\Worker; +use Assetic\Asset\AssetCollectionInterface; use Assetic\Asset\AssetInterface; +use Assetic\Factory\LazyAssetManager; /** * Adds cache busting code @@ -20,59 +22,51 @@ */ class CacheBustingWorker implements WorkerInterface { - const STRATEGY_CONTENT = 1; - const STRATEGY_MODIFICATION = 2; + protected $am; + private $separator; - private $strategy; - - public function __construct($strategy = self::STRATEGY_CONTENT) + public function __construct(LazyAssetManager $am, $separator = '-') { - $this->strategy = $strategy; + $this->am = $am; + $this->separator = $separator; } public function process(AssetInterface $asset) { - $hash = hash_init('sha1'); - - switch($this->strategy) { - case self::STRATEGY_MODIFICATION: - hash_update($hash, $asset->getLastModified()); - break; - case self::STRATEGY_CONTENT: - hash_update($hash, $asset->dump()); - break; + if (!$path = $asset->getTargetPath()) { + // no path to work with + return; } - foreach ($asset as $i => $leaf) { - if ($sourcePath = $leaf->getSourcePath()) { - hash_update($hash, $sourcePath); - } else { - hash_update($hash, $i); - } + if (!$search = pathinfo($path, PATHINFO_EXTENSION)) { + // nothing to replace + return; } - $hash = substr(hash_final($hash), 0, 7); - $url = $asset->getTargetPath(); - - $oldExt = pathinfo($url, PATHINFO_EXTENSION); - $newExt = '-'.$hash.'.'.$oldExt; - - if (!$oldExt || 0 < preg_match('/'.preg_quote($newExt, '/').'$/', $url)) { + $replace = $this->separator.$this->getHash($asset).'.'.$search; + if (preg_match('/'.preg_quote($replace, '/').'$/', $path)) { + // already replaced return; } - $asset->setTargetPath(substr($url, 0, (strlen($oldExt) + 1) * -1).$newExt); + $asset->setTargetPath( + preg_replace('/\.'.preg_quote($search, '/').'$/', $replace, $path) + ); } - public function getStrategy() + protected function getHash(AssetInterface $asset) { - return $this->strategy; - } + $hash = hash_init('sha1'); - public function setStrategy($strategy) - { - $this->strategy = $strategy; + hash_update($hash, $this->am->getLastModified($asset)); + + if ($asset instanceof AssetCollectionInterface) { + foreach ($asset as $i => $leaf) { + $sourcePath = $leaf->getSourcePath(); + hash_update($hash, $sourcePath ?: $i); + } + } - return $this; + return substr(hash_final($hash), 0, 7); } } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/BaseCssFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/BaseCssFilter.php index dd48fd1070da..0d9ff70061ca 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/BaseCssFilter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/BaseCssFilter.php @@ -11,6 +11,8 @@ namespace Assetic\Filter; +use Assetic\Util\CssUtils; + /** * An abstract filter for dealing with CSS. * @@ -19,71 +21,34 @@ abstract class BaseCssFilter implements FilterInterface { /** - * Filters all references -- url() and "@import" -- through a callable. - * - * @param string $content The CSS - * @param callable $callback A PHP callable - * @param integer $limit - * @param integer $count - * - * @return string The filtered CSS + * @see CssUtils::filterReferences() */ protected function filterReferences($content, $callback, $limit = -1, &$count = 0) { - $content = $this->filterUrls($content, $callback, $limit, $count); - $content = $this->filterImports($content, $callback, $limit, $count, false); - $content = $this->filterIEFilters($content, $callback, $limit, $count); - - return $content; + return CssUtils::filterReferences($content, $callback, $limit, $count); } /** - * Filters all CSS url()'s through a callable. - * - * @param string $content The CSS - * @param callable $callback A PHP callable - * @param integer $limit Limit the number of replacements - * @param integer $count Will be populated with the count - * - * @return string The filtered CSS + * @see CssUtils::filterUrls() */ protected function filterUrls($content, $callback, $limit = -1, &$count = 0) { - return preg_replace_callback('/url\((["\']?)(?P<url>.*?)(\\1)\)/', $callback, $content, $limit, $count); + return CssUtils::filterUrls($content, $callback, $limit, $count); } /** - * Filters all CSS imports through a callable. - * - * @param string $content The CSS - * @param callable $callback A PHP callable - * @param integer $limit Limit the number of replacements - * @param integer $count Will be populated with the count - * @param Boolean $includeUrl Whether to include url() in the pattern - * - * @return string The filtered CSS + * @see CssUtils::filterImports() */ protected function filterImports($content, $callback, $limit = -1, &$count = 0, $includeUrl = true) { - $pattern = $includeUrl - ? '/@import (?:url\()?(\'|"|)(?P<url>[^\'"\)\n\r]*)\1\)?;?/' - : '/@import (?!url\()(\'|"|)(?P<url>[^\'"\)\n\r]*)\1;?/'; - - return preg_replace_callback($pattern, $callback, $content, $limit, $count); + return CssUtils::filterImports($content, $callback, $limit, $count, $includeUrl); } /** - * Filters all IE filters (AlphaImageLoader filter) through a callable. - * - * @param string $content The CSS - * @param callable $callback A PHP callable - * @param integer $limit Limit the number of replacements - * @param integer $count Will be populated with the count - * - * @return string The filtered CSS + * @see CssUtils::filterIEFilters() */ protected function filterIEFilters($content, $callback, $limit = -1, &$count = 0) { - return preg_replace_callback('/src=(["\']?)(?P<url>.*?)\\1/', $callback, $content, $limit, $count); + return CssUtils::filterIEFilters($content, $callback, $limit, $count); } } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/BaseNodeFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/BaseNodeFilter.php index 1d86add9447a..d88e9cdaa840 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/BaseNodeFilter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/BaseNodeFilter.php @@ -36,6 +36,7 @@ protected function createProcessBuilder(array $arguments = array()) if ($this->nodePaths) { $pb->setEnv('NODE_PATH', implode(':', $this->nodePaths)); + $this->mergeEnv($pb); } return $pb; diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/BaseProcessFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/BaseProcessFilter.php index 684791663163..b049f65cbc28 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/BaseProcessFilter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/BaseProcessFilter.php @@ -48,4 +48,11 @@ protected function createProcessBuilder(array $arguments = array()) return $pb; } + + protected function mergeEnv(ProcessBuilder $pb) + { + foreach (array_filter($_SERVER, 'is_scalar') as $key => $value) { + $pb->setEnv($key, $value); + } + } } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php index d5ae6d0242a3..c32fc46d6dd0 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php @@ -11,8 +11,9 @@ namespace Assetic\Filter; -use Assetic\Exception\FilterException; use Assetic\Asset\AssetInterface; +use Assetic\Exception\FilterException; +use Assetic\Factory\AssetFactory; /** * Loads Compass files. @@ -20,7 +21,7 @@ * @link http://compass-style.org/ * @author Maxime Thirouin <maxime.thirouin@gmail.com> */ -class CompassFilter extends BaseProcessFilter +class CompassFilter extends BaseProcessFilter implements DependencyExtractorInterface { private $compassPath; private $rubyPath; @@ -210,7 +211,6 @@ public function filterLoad(AssetInterface $asset) } $pb = $this->createProcessBuilder($compassProcessArgs); - $pb->inheritEnvironmentVariables(); if ($this->force) { $pb->add('--force'); @@ -345,6 +345,7 @@ public function filterLoad(AssetInterface $asset) if ($this->homeEnv) { // it's not really usefull but... https://github.com/chriseppstein/compass/issues/376 $pb->setEnv('HOME', sys_get_temp_dir()); + $this->mergeEnv($pb); } $proc = $pb->getProcess(); @@ -372,6 +373,12 @@ public function filterDump(AssetInterface $asset) { } + public function getChildren(AssetFactory $factory, $content, $loadPath = null) + { + // todo + return array(); + } + private function formatArrayToRuby($array) { $output = array(); diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/CssEmbedFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/CssEmbedFilter.php index 34bd8827e993..e0c2c15937b1 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/CssEmbedFilter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/CssEmbedFilter.php @@ -13,6 +13,7 @@ use Assetic\Asset\AssetInterface; use Assetic\Exception\FilterException; +use Assetic\Factory\AssetFactory; /** * CSSEmbed filter @@ -20,7 +21,7 @@ * @link https://github.com/nzakas/cssembed * @author Maxime Thirouin <maxime.thirouin@gmail.com> */ -class CssEmbedFilter extends BaseProcessFilter +class CssEmbedFilter extends BaseProcessFilter implements DependencyExtractorInterface { private $jarPath; private $javaPath; @@ -135,4 +136,10 @@ public function filterDump(AssetInterface $asset) $asset->setContent($proc->getOutput()); } + + public function getChildren(AssetFactory $factory, $content, $loadPath = null) + { + // todo + return array(); + } } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/CssImportFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/CssImportFilter.php index 6bddfbee1496..82ff209ae802 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/CssImportFilter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/CssImportFilter.php @@ -14,13 +14,14 @@ use Assetic\Asset\AssetInterface; use Assetic\Asset\FileAsset; use Assetic\Asset\HttpAsset; +use Assetic\Factory\AssetFactory; /** * Inlines imported stylesheets. * * @author Kris Wallsmith <kris.wallsmith@gmail.com> */ -class CssImportFilter extends BaseCssFilter +class CssImportFilter extends BaseCssFilter implements DependencyExtractorInterface { private $importFilter; @@ -103,4 +104,10 @@ public function filterLoad(AssetInterface $asset) public function filterDump(AssetInterface $asset) { } + + public function getChildren(AssetFactory $factory, $content, $loadPath = null) + { + // todo + return array(); + } } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/DependencyExtractorInterface.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/DependencyExtractorInterface.php new file mode 100644 index 000000000000..934371f24bfb --- /dev/null +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/DependencyExtractorInterface.php @@ -0,0 +1,34 @@ +<?php + +/* + * This file is part of the Assetic package, an OpenSky project. + * + * (c) 2010-2013 OpenSky Project Inc + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Assetic\Filter; + +use Assetic\Asset\AssetInterface; +use Assetic\Factory\AssetFactory; + +/** + * A filter that knows how to extract dependencies. + * + * @author Kris Wallsmith <kris.wallsmith@gmail.com> + */ +interface DependencyExtractorInterface extends FilterInterface +{ + /** + * Returns child assets. + * + * @param AssetFactory $factory The asset factory + * @param string $content The asset content + * @param string $loadPath An optional load path + * + * @return AssetInterface[] Child assets + */ + public function getChildren(AssetFactory $factory, $content, $loadPath = null); +} diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/EmberPrecompileFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/EmberPrecompileFilter.php new file mode 100644 index 000000000000..2467960ec5e7 --- /dev/null +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/EmberPrecompileFilter.php @@ -0,0 +1,83 @@ +<?php + +/* + * This file is part of the Assetic package, an OpenSky project. + * + * (c) 2010-2013 OpenSky Project Inc + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Assetic\Filter; + +use Assetic\Asset\AssetInterface; +use Assetic\Exception\FilterException; + +/** + * Precompiles Handlebars templates for use in the Ember.js framework. This filter + * requires that the npm package ember-precompile be installed. You can find this + * package at https://github.com/gabrielgrant/node-ember-precompile. + * + * @link http://www.emberjs.com/ + * @author Jarrod Nettles <jarrod.nettles@icloud.com> + */ +class EmberPrecompileFilter extends BaseNodeFilter +{ + private $emberBin; + private $nodeBin; + + public function __construct($handlebarsBin = '/usr/bin/ember-precompile', $nodeBin = null) + { + $this->emberBin = $handlebarsBin; + $this->nodeBin = $nodeBin; + } + + public function filterLoad(AssetInterface $asset) + { + $pb = $this->createProcessBuilder($this->nodeBin + ? array($this->nodeBin, $this->emberBin) + : array($this->emberBin)); + + $templateName = basename($asset->getSourcePath()); + + $inputDirPath = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('input_dir'); + $inputPath = $inputDirPath.DIRECTORY_SEPARATOR.$templateName; + $outputPath = tempnam(sys_get_temp_dir(), 'output'); + + mkdir($inputDirPath); + file_put_contents($inputPath, $asset->getContent()); + + $pb->add($inputPath)->add('-f')->add($outputPath); + + $process = $pb->getProcess(); + $returnCode = $process->run(); + + unlink($inputPath); + rmdir($inputDirPath); + + if (127 === $returnCode) { + throw new \RuntimeException('Path to node executable could not be resolved.'); + } + + if (0 !== $returnCode) { + if (file_exists($outputPath)) { + unlink($outputPath); + } + throw FilterException::fromProcess($process)->setInput($asset->getContent()); + } + + if (!file_exists($outputPath)) { + throw new \RuntimeException('Error creating output file.'); + } + + $compiledJs = file_get_contents($outputPath); + unlink($outputPath); + + $asset->setContent($compiledJs); + } + + public function filterDump(AssetInterface $asset) + { + } +} diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/GoogleClosure/CompilerApiFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/GoogleClosure/CompilerApiFilter.php index 5ea76812ef3c..0b090c74d92f 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/GoogleClosure/CompilerApiFilter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/GoogleClosure/CompilerApiFilter.php @@ -101,7 +101,7 @@ public function filterDump(AssetInterface $asset) curl_setopt($ch, CURLOPT_POSTFIELDS, $query); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); if (null !== $this->timeout) { - curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout); + curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); } if ($this->proxy) { curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE); diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/LessFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/LessFilter.php index d247ddd42e70..4acd38f9d345 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/LessFilter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/LessFilter.php @@ -13,6 +13,8 @@ use Assetic\Asset\AssetInterface; use Assetic\Exception\FilterException; +use Assetic\Factory\AssetFactory; +use Assetic\Util\LessUtils; /** * Loads LESS files. @@ -20,10 +22,19 @@ * @link http://lesscss.org/ * @author Kris Wallsmith <kris.wallsmith@gmail.com> */ -class LessFilter extends BaseNodeFilter +class LessFilter extends BaseNodeFilter implements DependencyExtractorInterface { private $nodeBin; - private $compress; + + /** + * @var array + */ + private $treeOptions; + + /** + * @var array + */ + private $parserOptions; /** * Load Paths @@ -44,11 +55,21 @@ public function __construct($nodeBin = '/usr/bin/node', array $nodePaths = array { $this->nodeBin = $nodeBin; $this->setNodePaths($nodePaths); + $this->treeOptions = array(); + $this->parserOptions = array(); } + /** + * @param bool $compress + */ public function setCompress($compress) { - $this->compress = $compress; + $this->addTreeOption('compress', $compress); + } + + public function setLoadPaths(array $loadPaths) + { + $this->loadPaths = $loadPaths; } /** @@ -61,6 +82,24 @@ public function addLoadPath($path) $this->loadPaths[] = $path; } + /** + * @param string $code + * @param string $value + */ + public function addTreeOption($code, $value) + { + $this->treeOptions[$code] = $value; + } + + /** + * @param string $code + * @param string $value + */ + public function addParserOption($code, $value) + { + $this->parserOptions[$code] = $value; + } + public function filterLoad(AssetInterface $asset) { static $format = <<<'EOF' @@ -87,29 +126,23 @@ public function filterLoad(AssetInterface $asset) $path = $asset->getSourcePath(); // parser options - $parserOptions = array(); + $parserOptions = $this->parserOptions; if ($root && $path) { $parserOptions['paths'] = array(dirname($root.'/'.$path)); $parserOptions['filename'] = basename($path); } + foreach ($this->loadPaths as $loadPath) { $parserOptions['paths'][] = $loadPath; } - // tree options - $treeOptions = array(); - if (null !== $this->compress) { - $treeOptions['compress'] = $this->compress; - } - $pb = $this->createProcessBuilder(); - $pb->inheritEnvironmentVariables(); $pb->add($this->nodeBin)->add($input = tempnam(sys_get_temp_dir(), 'assetic_less')); file_put_contents($input, sprintf($format, json_encode($parserOptions), json_encode($asset->getContent()), - json_encode($treeOptions) + json_encode($this->treeOptions) )); $proc = $pb->getProcess(); @@ -126,4 +159,48 @@ public function filterLoad(AssetInterface $asset) public function filterDump(AssetInterface $asset) { } + + /** + * @todo support for @import-once + * @todo support for @import (less) "lib.css" + */ + public function getChildren(AssetFactory $factory, $content, $loadPath = null) + { + $loadPaths = $this->loadPaths; + if (null !== $loadPath) { + $loadPaths[] = $loadPath; + } + + if (empty($loadPaths)) { + return array(); + } + + $children = array(); + foreach (LessUtils::extractImports($content) as $reference) { + if ('.css' === substr($reference, -4)) { + // skip normal css imports + // todo: skip imports with media queries + continue; + } + + if ('.less' !== substr($reference, -5)) { + $reference .= '.less'; + } + + foreach ($loadPaths as $loadPath) { + if (file_exists($file = $loadPath.'/'.$reference)) { + $coll = $factory->createAsset($file, array(), array('root' => $loadPath)); + foreach ($coll as $leaf) { + $leaf->ensureFilter($this); + $children[] = $leaf; + goto next_reference; + } + } + } + + next_reference: + } + + return $children; + } } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/LessphpFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/LessphpFilter.php index d87ac16373a6..fe82412d2e0f 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/LessphpFilter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/LessphpFilter.php @@ -12,6 +12,8 @@ namespace Assetic\Filter; use Assetic\Asset\AssetInterface; +use Assetic\Factory\AssetFactory; +use Assetic\Util\LessUtils; /** * Loads LESS files using the PHP implementation of less, lessphp. @@ -23,7 +25,7 @@ * @author David Buchmann <david@liip.ch> * @author Kris Wallsmith <kris.wallsmith@gmail.com> */ -class LessphpFilter implements FilterInterface +class LessphpFilter implements DependencyExtractorInterface { private $presets = array(); private $formatter; @@ -46,6 +48,16 @@ public function addLoadPath($path) $this->loadPaths[] = $path; } + /** + * Sets load paths used by lessphp + * + * @param array $loadPaths Load paths + */ + public function setLoadPaths(array $loadPaths) + { + $this->loadPaths = $loadPaths; + } + public function setPresets(array $presets) { $this->presets = $presets; @@ -95,4 +107,44 @@ public function filterLoad(AssetInterface $asset) public function filterDump(AssetInterface $asset) { } + + public function getChildren(AssetFactory $factory, $content, $loadPath = null) + { + $loadPaths = $this->loadPaths; + if (null !== $loadPath) { + $loadPaths[] = $loadPath; + } + + if (empty($loadPaths)) { + return array(); + } + + $children = array(); + foreach (LessUtils::extractImports($content) as $reference) { + if ('.css' === substr($reference, -4)) { + // skip normal css imports + // todo: skip imports with media queries + continue; + } + + if ('.less' !== substr($reference, -5)) { + $reference .= '.less'; + } + + foreach ($loadPaths as $loadPath) { + if (file_exists($file = $loadPath.'/'.$reference)) { + $coll = $factory->createAsset($file, array(), array('root' => $loadPath)); + foreach ($coll as $leaf) { + $leaf->ensureFilter($this); + $children[] = $leaf; + goto next_reference; + } + } + } + + next_reference: + } + + return $children; + } } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/PhpCssEmbedFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/PhpCssEmbedFilter.php index 8185beb79aa2..5df4423ff89b 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/PhpCssEmbedFilter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/PhpCssEmbedFilter.php @@ -12,6 +12,7 @@ namespace Assetic\Filter; use Assetic\Asset\AssetInterface; +use Assetic\Factory\AssetFactory; use CssEmbed\CssEmbed; /** @@ -20,7 +21,7 @@ * @author Pierre Tachoire <pierre.tachoire@gmail.com> * @link https://github.com/krichprollsch/phpCssEmbed */ -class PhpCssEmbedFilter implements FilterInterface +class PhpCssEmbedFilter implements DependencyExtractorInterface { private $presets = array(); @@ -45,4 +46,10 @@ public function filterLoad(AssetInterface $asset) public function filterDump(AssetInterface $asset) { } + + public function getChildren(AssetFactory $factory, $content, $loadPath = null) + { + // todo + return array(); + } } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/RooleFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/RooleFilter.php new file mode 100644 index 000000000000..59585d32b708 --- /dev/null +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/RooleFilter.php @@ -0,0 +1,73 @@ +<?php + +/* + * This file is part of the Assetic package, an OpenSky project. + * + * (c) 2010-2013 OpenSky Project Inc + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Assetic\Filter; + +use Assetic\Asset\AssetInterface; +use Assetic\Exception\FilterException; +use Assetic\Factory\AssetFactory; + +/** + * Loads Roole files. + * + * @link http://roole.org + * @author Marcin Chwedziak <tiraeth@gmail.com> + */ +class RooleFilter extends BaseNodeFilter implements DependencyExtractorInterface +{ + private $rooleBin; + private $nodeBin; + + /** + * Constructor + * + * @param string $rooleBin The path to the roole binary + * @param string $nodeBin The path to the node binary + */ + public function __construct($rooleBin = '/usr/bin/roole', $nodeBin = null) + { + $this->rooleBin = $rooleBin; + $this->nodeBin = $nodeBin; + } + + public function filterLoad(AssetInterface $asset) + { + $input = tempnam(sys_get_temp_dir(), 'assetic_roole'); + file_put_contents($input, $asset->getContent()); + + $pb = $this->createProcessBuilder($this->nodeBin + ? array($this->nodeBin, $this->rooleBin) + : array($this->rooleBin)); + + $pb->add('-p'); + + $pb->add($input); + $proc = $pb->getProcess(); + $code = $proc->run(); + unlink($input); + + if (0 !== $code) { + throw FilterException::fromProcess($proc)->setInput($asset->getContent()); + } + + $asset->setContent($proc->getOutput()); + } + + public function filterDump(AssetInterface $asset) + { + } + + public function getChildren(AssetFactory $factory, $content, $loadPath = null) + { + // todo + return array(); + } +} diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/Sass/SassFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/Sass/SassFilter.php index bba8f98e6f8e..24e618dd5507 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/Sass/SassFilter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/Sass/SassFilter.php @@ -13,7 +13,10 @@ use Assetic\Asset\AssetInterface; use Assetic\Exception\FilterException; +use Assetic\Factory\AssetFactory; use Assetic\Filter\BaseProcessFilter; +use Assetic\Filter\DependencyExtractorInterface; +use Assetic\Util\CssUtils; /** * Loads SASS files. @@ -21,7 +24,7 @@ * @link http://sass-lang.com/ * @author Kris Wallsmith <kris.wallsmith@gmail.com> */ -class SassFilter extends BaseProcessFilter +class SassFilter extends BaseProcessFilter implements DependencyExtractorInterface { const STYLE_NESTED = 'nested'; const STYLE_EXPANDED = 'expanded'; @@ -78,6 +81,11 @@ public function setLineNumbers($lineNumbers) $this->lineNumbers = $lineNumbers; } + public function setLoadPaths(array $loadPaths) + { + $this->loadPaths = $loadPaths; + } + public function addLoadPath($loadPath) { $this->loadPaths[] = $loadPath; @@ -172,4 +180,57 @@ public function filterLoad(AssetInterface $asset) public function filterDump(AssetInterface $asset) { } + + public function getChildren(AssetFactory $factory, $content, $loadPath = null) + { + $loadPaths = $this->loadPaths; + if ($loadPath) { + array_unshift($loadPaths, $loadPath); + } + + if (!$loadPaths) { + return array(); + } + + $children = array(); + foreach (CssUtils::extractImports($content) as $reference) { + if ('.css' === substr($reference, -4)) { + // skip normal css imports + // todo: skip imports with media queries + continue; + } + + // the reference may or may not have an extension or be a partial + if (pathinfo($reference, PATHINFO_EXTENSION)) { + $needles = array( + $reference, + '_'.$reference, + ); + } else { + $needles = array( + $reference.'.scss', + $reference.'.sass', + '_'.$reference.'.scss', + '_'.$reference.'.sass', + ); + } + + foreach ($loadPaths as $loadPath) { + foreach ($needles as $needle) { + if (file_exists($file = $loadPath.'/'.$needle)) { + $coll = $factory->createAsset($file, array(), array('root' => $loadPath)); + foreach ($coll as $leaf) { + $leaf->ensureFilter($this); + $children[] = $leaf; + goto next_reference; + } + } + } + } + + next_reference: + } + + return $children; + } } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/ScssphpFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/ScssphpFilter.php index dccf945749a9..db5c0684242d 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/ScssphpFilter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/ScssphpFilter.php @@ -12,6 +12,7 @@ namespace Assetic\Filter; use Assetic\Asset\AssetInterface; +use Assetic\Factory\AssetFactory; /** * Loads SCSS files using the PHP implementation of scss, scssphp. @@ -22,7 +23,7 @@ * * @author Bart van den Burg <bart@samson-it.nl> */ -class ScssphpFilter implements FilterInterface +class ScssphpFilter implements DependencyExtractorInterface { private $compass = false; @@ -70,4 +71,10 @@ public function addImportPath($path) public function filterDump(AssetInterface $asset) { } + + public function getChildren(AssetFactory $factory, $content, $loadPath = null) + { + // todo + return array(); + } } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/SprocketsFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/SprocketsFilter.php index 8f0d8d96bbd7..b305ad2ac13d 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/SprocketsFilter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/SprocketsFilter.php @@ -13,6 +13,7 @@ use Assetic\Asset\AssetInterface; use Assetic\Exception\FilterException; +use Assetic\Factory\AssetFactory; /** * Runs assets through Sprockets. @@ -24,7 +25,7 @@ * * @author Kris Wallsmith <kris.wallsmith@gmail.com> */ -class SprocketsFilter extends BaseProcessFilter +class SprocketsFilter extends BaseProcessFilter implements DependencyExtractorInterface { private $sprocketsLib; private $rubyBin; @@ -122,6 +123,12 @@ public function filterDump(AssetInterface $asset) { } + public function getChildren(AssetFactory $factory, $content, $loadPath = null) + { + // todo + return array(); + } + private function getHack(AssetInterface $asset) { static $format = <<<'EOF' diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/StylusFilter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/StylusFilter.php index f454b563e102..c7cc7b54542e 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/StylusFilter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/StylusFilter.php @@ -13,6 +13,7 @@ use Assetic\Asset\AssetInterface; use Assetic\Exception\FilterException; +use Assetic\Factory\AssetFactory; /** * Loads STYL files. @@ -20,7 +21,7 @@ * @link http://learnboost.github.com/stylus/ * @author Konstantin Kudryashov <ever.zet@gmail.com> */ -class StylusFilter extends BaseNodeFilter +class StylusFilter extends BaseNodeFilter implements DependencyExtractorInterface { private $nodeBin; private $compress; @@ -82,7 +83,6 @@ public function filterLoad(AssetInterface $asset) } $pb = $this->createProcessBuilder(); - $pb->inheritEnvironmentVariables(); $pb->add($this->nodeBin)->add($input = tempnam(sys_get_temp_dir(), 'assetic_stylus')); file_put_contents($input, sprintf($format, @@ -107,4 +107,10 @@ public function filterLoad(AssetInterface $asset) public function filterDump(AssetInterface $asset) { } + + public function getChildren(AssetFactory $factory, $content, $loadPath = null) + { + // todo + return array(); + } } diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/UglifyJs2Filter.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/UglifyJs2Filter.php index d30ed1bea089..15d314e49378 100644 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/UglifyJs2Filter.php +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/UglifyJs2Filter.php @@ -27,6 +27,9 @@ class UglifyJs2Filter extends BaseNodeFilter private $compress; private $beautify; private $mangle; + private $screwIe8; + private $comments; + private $wrap; public function __construct($uglifyjsBin = '/usr/bin/uglifyjs', $nodeBin = null) { @@ -49,6 +52,21 @@ public function setMangle($mangle) $this->mangle = $mangle; } + public function setScrewIe8($screwIe8) + { + $this->screwIe8 = $screwIe8; + } + + public function setComments($comments) + { + $this->comments = $comments; + } + + public function setWrap($wrap) + { + $this->wrap = $wrap; + } + public function filterLoad(AssetInterface $asset) { } @@ -71,6 +89,18 @@ public function filterDump(AssetInterface $asset) $pb->add('--mangle'); } + if ($this->screwIe8) { + $pb->add('--screw-ie8'); + } + + if ($this->comments) { + $pb->add('--comments')->add(true === $this->comments ? 'all' : $this->comments); + } + + if ($this->wrap) { + $pb->add('--wrap')->add($this->wrap); + } + // input and output files $input = tempnam(sys_get_temp_dir(), 'input'); $output = tempnam(sys_get_temp_dir(), 'output'); diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Util/CssUtils.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Util/CssUtils.php new file mode 100644 index 000000000000..00d658bb779f --- /dev/null +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Util/CssUtils.php @@ -0,0 +1,111 @@ +<?php + +/* + * This file is part of the Assetic package, an OpenSky project. + * + * (c) 2010-2013 OpenSky Project Inc + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Assetic\Util; + +/** + * CSS Utils. + * + * @author Kris Wallsmith <kris.wallsmith@gmail.com> + */ +abstract class CssUtils +{ + const REGEX_URLS = '/url\((["\']?)(?P<url>.*?)(\\1)\)/'; + const REGEX_IMPORTS = '/@import (?:url\()?(\'|"|)(?P<url>[^\'"\)\n\r]*)\1\)?;?/'; + const REGEX_IMPORTS_NO_URLS = '/@import (?!url\()(\'|"|)(?P<url>[^\'"\)\n\r]*)\1;?/'; + const REGEX_IE_FILTERS = '/src=(["\']?)(?P<url>.*?)\\1/'; + + /** + * Filters all references -- url() and "@import" -- through a callable. + * + * @param string $content The CSS + * @param callable $callback A PHP callable + * @param integer $limit + * @param integer $count + * + * @return string The filtered CSS + */ + public static function filterReferences($content, $callback, $limit = -1, &$count = 0) + { + $content = static::filterUrls($content, $callback, $limit, $count); + $content = static::filterImports($content, $callback, $limit, $count, false); + $content = static::filterIEFilters($content, $callback, $limit, $count); + + return $content; + } + + /** + * Filters all CSS url()'s through a callable. + * + * @param string $content The CSS + * @param callable $callback A PHP callable + * @param integer $limit Limit the number of replacements + * @param integer $count Will be populated with the count + * + * @return string The filtered CSS + */ + public static function filterUrls($content, $callback, $limit = -1, &$count = 0) + { + return preg_replace_callback(static::REGEX_URLS, $callback, $content, $limit, $count); + } + + /** + * Filters all CSS imports through a callable. + * + * @param string $content The CSS + * @param callable $callback A PHP callable + * @param integer $limit Limit the number of replacements + * @param integer $count Will be populated with the count + * @param Boolean $includeUrl Whether to include url() in the pattern + * + * @return string The filtered CSS + */ + public static function filterImports($content, $callback, $limit = -1, &$count = 0, $includeUrl = true) + { + $pattern = $includeUrl ? static::REGEX_IMPORTS : static::REGEX_IMPORTS_NO_URLS; + + return preg_replace_callback($pattern, $callback, $content, $limit, $count); + } + + /** + * Filters all IE filters (AlphaImageLoader filter) through a callable. + * + * @param string $content The CSS + * @param callable $callback A PHP callable + * @param integer $limit Limit the number of replacements + * @param integer $count Will be populated with the count + * + * @return string The filtered CSS + */ + public static function filterIEFilters($content, $callback, $limit = -1, &$count = 0) + { + return preg_replace_callback(static::REGEX_IE_FILTERS, $callback, $content, $limit, $count); + } + + /** + * Extracts all references from the supplied CSS content. + * + * @param string $content The CSS content + * + * @return array An array of unique URLs + */ + public static function extractImports($content) + { + $imports = array(); + static::filterImports($content, function($matches) use(& $imports) { + $imports[] = $matches['url']; + }); + + return array_unique($imports); + } + + final private function __construct() { } +} diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Util/LessUtils.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Util/LessUtils.php new file mode 100644 index 000000000000..291fb662482b --- /dev/null +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Util/LessUtils.php @@ -0,0 +1,23 @@ +<?php + +/* + * This file is part of the Assetic package, an OpenSky project. + * + * (c) 2010-2013 OpenSky Project Inc + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Assetic\Util; + +/** + * Less Utils. + * + * @author Kris Wallsmith <kris.wallsmith@gmail.com> + */ +abstract class LessUtils extends CssUtils +{ + const REGEX_IMPORTS = '/@import(?:-once)? (?:url\()?(\'|"|)(?P<url>[^\'"\)\n\r]*)\1\)?;?/'; + const REGEX_IMPORTS_NO_URLS = '/@import(?:-once)? (?!url\()(\'|"|)(?P<url>[^\'"\)\n\r]*)\1;?/'; +} diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Util/PathUtils.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Util/PathUtils.php deleted file mode 100644 index 4a54353d9258..000000000000 --- a/core/vendor/kriswallsmith/assetic/src/Assetic/Util/PathUtils.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -/* - * This file is part of the Assetic package, an OpenSky project. - * - * (c) 2010-2013 OpenSky Project Inc - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Assetic\Util; - -/** - * Path Utils. - * - * @author Johannes M. Schmitt <schmittjoh@gmail.com> - */ -abstract class PathUtils -{ - public static function resolvePath($path, array $vars, array $values) - { - $map = array(); - foreach ($vars as $var) { - if (false === strpos($path, '{'.$var.'}')) { - continue; - } - - if (!isset($values[$var])) { - throw new \InvalidArgumentException(sprintf('The path "%s" contains the variable "%s", but was not given any value for it.', $path, $var)); - } - - $map['{'.$var.'}'] = $values[$var]; - } - - return strtr($path, $map); - } - - final private function __construct() { } -} diff --git a/core/vendor/kriswallsmith/assetic/src/Assetic/Util/VarUtils.php b/core/vendor/kriswallsmith/assetic/src/Assetic/Util/VarUtils.php new file mode 100644 index 000000000000..4cc9103c5df7 --- /dev/null +++ b/core/vendor/kriswallsmith/assetic/src/Assetic/Util/VarUtils.php @@ -0,0 +1,82 @@ +<?php + +/* + * This file is part of the Assetic package, an OpenSky project. + * + * (c) 2010-2013 OpenSky Project Inc + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Assetic\Util; + +/** + * Variable utilities. + * + * @author Johannes M. Schmitt <schmittjoh@gmail.com> + */ +abstract class VarUtils +{ + /** + * Resolves variable placeholders. + * + * @param string $template A template string + * @param array $vars Variable names + * @param array $values Variable values + * + * @return string The resolved string + * + * @throws \InvalidArgumentException If there is a variable with no value + */ + public static function resolve($template, array $vars, array $values) + { + $map = array(); + foreach ($vars as $var) { + if (false === strpos($template, '{'.$var.'}')) { + continue; + } + + if (!isset($values[$var])) { + throw new \InvalidArgumentException(sprintf('The path "%s" contains the variable "%s", but was not given any value for it.', $template, $var)); + } + + $map['{'.$var.'}'] = $values[$var]; + } + + return strtr($template, $map); + } + + public static function getCombinations(array $vars, array $values) + { + if (!$vars) { + return array(array()); + } + + $combinations = array(); + $nbValues = array(); + foreach ($values as $var => $vals) { + if (!in_array($var, $vars, true)) { + continue; + } + + $nbValues[$var] = count($vals); + } + + for ($i = array_product($nbValues), $c = $i * 2; $i < $c; $i++) { + $k = $i; + $combination = array(); + + foreach ($vars as $var) { + $combination[$var] = $values[$var][$k % $nbValues[$var]]; + $k = intval($k / $nbValues[$var]); + } + + $combinations[] = $combination; + } + + return $combinations; + } + + final private function __construct() { } +} diff --git a/core/vendor/phpunit/php-code-coverage/.gitignore b/core/vendor/phpunit/php-code-coverage/.gitignore index a7419836bf19..82b141c43538 100644 --- a/core/vendor/phpunit/php-code-coverage/.gitignore +++ b/core/vendor/phpunit/php-code-coverage/.gitignore @@ -5,3 +5,5 @@ build/logs build/pdepend cache.properties phpunit.xml +/vendor +/composer.lock diff --git a/core/vendor/phpunit/php-code-coverage/ChangeLog.markdown b/core/vendor/phpunit/php-code-coverage/ChangeLog.markdown index 83c25db86719..60099511088e 100644 --- a/core/vendor/phpunit/php-code-coverage/ChangeLog.markdown +++ b/core/vendor/phpunit/php-code-coverage/ChangeLog.markdown @@ -3,6 +3,18 @@ PHP_CodeCoverage 1.2 This is the list of changes for the PHP_CodeCoverage 1.2 release series. +PHP_CodeCoverage 1.2.11 +----------------------- + +* Fixed #151: Blacklisted PHPUnit Phar. +* Fixed sebastianbergmann/phpunit#924. + +PHP_CodeCoverage 1.2.10 +----------------------- + +* Fixed #158: Executable code on a line that has a comment is processed incorrectly. +* Eliminated the coupling to `PHPUnit_Util_Printer` in `PHP_CodeCoverage_Report_Text`. + PHP_CodeCoverage 1.2.9 ---------------------- @@ -64,6 +76,6 @@ PHP_CodeCoverage 1.2.0 * The HTML report has been redesigned. * The new `@coversDefaultClass` annotation enables short `@covers` annotations when working with long class names or namespaces. -* The new `@coversNothing` annotation can be used so tests do not record any code coverage. Useful for integration testing. +* The new `@coversNothing` annotation can be used so tests do not record any code coverage. Useful for integration testing. * When `processUncoveredFilesFromWhitelist=FALSE` is set then files that are whitelisted but not covered by a single test are now included in the code coverage but with all lines, including those that are not executable, counted as not executed. * PHP_CodeCoverage 1.2 is only supported on PHP 5.3.3 (or later) and PHP 5.4.7 (or later) is highly recommended. diff --git a/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage.php b/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage.php index 7f051f297111..041d01d9365f 100644 --- a/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage.php +++ b/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage.php @@ -620,7 +620,7 @@ protected function getLinesToBeCovered($className, $methodName) } $classShortcut = preg_match_all( - '(@coversDefaultClass\s+(?P<coveredClass>.*?)\s*$)m', + '(@coversDefaultClass\s+(?P<coveredClass>[^\s]++)\s*$)m', $class->getDocComment(), $matches ); @@ -639,7 +639,7 @@ protected function getLinesToBeCovered($className, $methodName) } $match = preg_match_all( - '(@covers\s+(?P<coveredElement>.*?)\s*(\(\s*\))?\s*$)m', + '(@covers\s+(?P<coveredElement>[^\s()]++)[\s()]*$)m', $docComment, $matches ); diff --git a/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Autoload.php b/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Autoload.php index 32891403f63c..eeeb4ca72e27 100644 --- a/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Autoload.php +++ b/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Autoload.php @@ -43,6 +43,10 @@ * @since File available since Release 1.1.0 */ +if (defined('PHPUNIT_COMPOSER_INSTALL')) { + return; +} + require_once 'File/Iterator/Autoload.php'; require_once 'PHP/Token/Stream/Autoload.php'; require_once 'Text/Template/Autoload.php'; diff --git a/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Autoload.php.in b/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Autoload.php.in index 3df43be5c1d4..c7db4e39ad82 100644 --- a/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Autoload.php.in +++ b/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Autoload.php.in @@ -43,6 +43,10 @@ * @since File available since Release 1.1.0 */ +if (defined('PHPUNIT_COMPOSER_INSTALL')) { + return; +} + require_once 'File/Iterator/Autoload.php'; require_once 'PHP/Token/Stream/Autoload.php'; require_once 'Text/Template/Autoload.php'; diff --git a/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Filter.php b/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Filter.php index 966a0b9eaba0..586a65c0e5b8 100644 --- a/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Filter.php +++ b/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Filter.php @@ -304,6 +304,10 @@ public function hasWhitelist() */ protected function prefillBlacklist() { + if (defined('__PHPUNIT_PHAR__')) { + $this->addFileToBlacklist(__PHPUNIT_PHAR__); + } + $this->addDirectoryContainingClassToBlacklist('File_Iterator'); $this->addDirectoryContainingClassToBlacklist('PHP_CodeCoverage'); $this->addDirectoryContainingClassToBlacklist('PHP_Invoker'); diff --git a/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Util.php b/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Util.php index 26a2841351fd..5a4673ccdd82 100644 --- a/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Util.php +++ b/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Util.php @@ -114,25 +114,9 @@ public static function getLinesToBeIgnored($filename, $cacheTokens = TRUE) switch (get_class($token)) { case 'PHP_Token_COMMENT': case 'PHP_Token_DOC_COMMENT': { - $count = substr_count($token, "\n"); - $line = $token->getLine(); - - for ($i = $line; $i < $line + $count; $i++) { - self::$ignoredLines[$filename][$i] = TRUE; - } - - if ($token instanceof PHP_Token_DOC_COMMENT) { - // Workaround for the fact the DOC_COMMENT token - // does not include the final \n character in its - // text. - if (substr(trim($lines[$i-1]), -2) == '*/') { - self::$ignoredLines[$filename][$i] = TRUE; - } - - break; - } $_token = trim($token); + $_line = trim($lines[$token->getLine() - 1]); if ($_token == '// @codeCoverageIgnore' || $_token == '//@codeCoverageIgnore') { @@ -149,6 +133,26 @@ public static function getLinesToBeIgnored($filename, $cacheTokens = TRUE) $_token == '//@codeCoverageIgnoreEnd') { $stop = TRUE; } + + // be sure the comment doesn't have some token BEFORE it on the same line... + // it would not be safe to ignore the whole line in those cases. + if (0 === strpos($_token, $_line)) { + $count = substr_count($token, "\n"); + $line = $token->getLine(); + + for ($i = $line; $i < $line + $count; $i++) { + self::$ignoredLines[$filename][$i] = TRUE; + } + + if ($token instanceof PHP_Token_DOC_COMMENT) { + // Workaround for the fact the DOC_COMMENT token + // does not include the final \n character in its + // text. + if (substr(trim($lines[$i-1]), -2) == '*/') { + self::$ignoredLines[$filename][$i] = TRUE; + } + } + } } break; diff --git a/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Version.php b/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Version.php index b5251484e025..74edb6869d2e 100644 --- a/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Version.php +++ b/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Version.php @@ -56,7 +56,7 @@ */ class PHP_CodeCoverage_Version { - const VERSION = '1.2.9'; + const VERSION = '1.2.11'; protected static $version; /** diff --git a/core/vendor/phpunit/php-code-coverage/README.markdown b/core/vendor/phpunit/php-code-coverage/README.markdown index 559afa71e24c..61d7837af212 100644 --- a/core/vendor/phpunit/php-code-coverage/README.markdown +++ b/core/vendor/phpunit/php-code-coverage/README.markdown @@ -1,18 +1,17 @@ -PHP_CodeCoverage -================ +# PHP_CodeCoverage **PHP_CodeCoverage** is a library that provides collection, processing, and rendering functionality for PHP code coverage information. -Requirements ------------- +## Requirements * PHP_CodeCoverage 1.2 requires PHP 5.3.3 (or later) but PHP 5.4.7 (or later) is highly recommended. * [Xdebug](http://xdebug.org/) 2.0.5 (or later) is required but Xdebug 2.2.1 (or later) is highly recommended. -Installation ------------- +## Installation -PHP_CodeCoverage should be installed using the PEAR Installer, the backbone of the [PHP Extension and Application Repository](http://pear.php.net/) that provides a distribution system for PHP packages. +You can use the [PEAR Installer](http://pear.php.net/manual/en/guide.users.commandline.cli.php) or [Composer](http://getcomposer.org/) to download and install PHP_CodeCoverage as well as its dependencies + +### PEAR Installer Depending on your OS distribution and/or your PHP environment, you may need to install PEAR or update your existing PEAR installation before you can proceed with the following instructions. `sudo pear upgrade PEAR` usually suffices to upgrade an existing PEAR installation. The [PEAR Manual ](http://pear.php.net/manual/en/installation.getting.php) explains how to perform a fresh installation of PEAR. @@ -23,21 +22,32 @@ The following two commands (which you may have to run as `root`) are all that is After the installation you can find the PHP_CodeCoverage source files inside your local PEAR directory; the path is usually `/usr/lib/php/PHP/CodeCoverage`. -Using the PHP_CodeCoverage API ------------------------------- +### Composer + +To add PHP_CodeCoverage as a local, per-project dependency to your project, simply add a dependency on `phpunit/php-code-coverage` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on PHP_CodeCoverage 1.2: + + { + "require": { + "phpunit/php-code-coverage": ">=1.2.10,<1.3.0" + } + } + +## Using the PHP_CodeCoverage API - <?php - require 'PHP/CodeCoverage/Autoload.php'; +```php +<?php +require 'PHP/CodeCoverage/Autoload.php'; - $coverage = new PHP_CodeCoverage; - $coverage->start('<name of test>'); +$coverage = new PHP_CodeCoverage; +$coverage->start('<name of test>'); - // ... +// ... - $coverage->stop(); +$coverage->stop(); - $writer = new PHP_CodeCoverage_Report_Clover; - $writer->process($coverage, '/tmp/clover.xml'); +$writer = new PHP_CodeCoverage_Report_Clover; +$writer->process($coverage, '/tmp/clover.xml'); - $writer = new PHP_CodeCoverage_Report_HTML; - $writer->process($coverage, '/tmp/code-coverage-report'); +$writer = new PHP_CodeCoverage_Report_HTML; +$writer->process($coverage, '/tmp/code-coverage-report'); +``` \ No newline at end of file diff --git a/core/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/FilterTest.php b/core/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/FilterTest.php index f90e518f1f1e..be8b71ee5cb3 100644 --- a/core/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/FilterTest.php +++ b/core/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/FilterTest.php @@ -78,8 +78,12 @@ protected function setUp() TEST_FILES_PATH . 'BankAccountTest.php', TEST_FILES_PATH . 'CoverageClassExtendedTest.php', TEST_FILES_PATH . 'CoverageClassTest.php', + TEST_FILES_PATH . 'CoverageFunctionParenthesesTest.php', + TEST_FILES_PATH . 'CoverageFunctionParenthesesWhitespaceTest.php', TEST_FILES_PATH . 'CoverageFunctionTest.php', TEST_FILES_PATH . 'CoverageMethodOneLineAnnotationTest.php', + TEST_FILES_PATH . 'CoverageMethodParenthesesTest.php', + TEST_FILES_PATH . 'CoverageMethodParenthesesWhitespaceTest.php', TEST_FILES_PATH . 'CoverageMethodTest.php', TEST_FILES_PATH . 'CoverageNoneTest.php', TEST_FILES_PATH . 'CoverageNotPrivateTest.php', diff --git a/core/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/UtilTest.php b/core/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/UtilTest.php index ed6b0f7cbee0..f23ad7236c53 100644 --- a/core/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/UtilTest.php +++ b/core/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/UtilTest.php @@ -55,8 +55,12 @@ require_once TEST_FILES_PATH . 'CoverageClassExtendedTest.php'; require_once TEST_FILES_PATH . 'CoverageClassTest.php'; require_once TEST_FILES_PATH . 'CoverageFunctionTest.php'; +require_once TEST_FILES_PATH . 'CoverageFunctionParenthesesTest.php'; +require_once TEST_FILES_PATH . 'CoverageFunctionParenthesesWhitespaceTest.php'; require_once TEST_FILES_PATH . 'CoverageMethodTest.php'; require_once TEST_FILES_PATH . 'CoverageMethodOneLineAnnotationTest.php'; +require_once TEST_FILES_PATH . 'CoverageMethodParenthesesTest.php'; +require_once TEST_FILES_PATH . 'CoverageMethodParenthesesWhitespaceTest.php'; require_once TEST_FILES_PATH . 'CoverageNoneTest.php'; require_once TEST_FILES_PATH . 'CoverageNotPrivateTest.php'; require_once TEST_FILES_PATH . 'CoverageNotProtectedTest.php'; @@ -164,17 +168,29 @@ public function testGetLinesToBeIgnoredOneLineAnnotations() array( 1 => TRUE, 2 => TRUE, - 7 => TRUE, 3 => TRUE, 4 => TRUE, 5 => TRUE, 6 => TRUE, + 7 => TRUE, 8 => TRUE, 9 => TRUE, 10 => TRUE, 11 => TRUE, 12 => TRUE, - 13 => TRUE + 13 => TRUE, + 14 => TRUE, + 17 => TRUE, + 19 => TRUE, + 22 => TRUE, + 23 => TRUE, + 27 => TRUE, + 28 => TRUE, + 29 => TRUE, + 30 => TRUE, + 31 => TRUE, + 32 => TRUE, + 33 => TRUE, ), PHP_CodeCoverage_Util::getLinesToBeIgnored( TEST_FILES_PATH . 'source_with_oneline_annotations.php' diff --git a/core/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverageTest.php b/core/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverageTest.php index 582b0a8365db..228175166d03 100644 --- a/core/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverageTest.php +++ b/core/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverageTest.php @@ -234,13 +234,10 @@ public function testClear() } /** - * Add parenthesis to the covers annotation below in a couple of different ways to make sure it - * works as expected - * - * @covers PHP_CodeCoverage::start() - * @covers PHP_CodeCoverage::stop( ) - * @covers PHP_CodeCoverage::append () - * @covers PHP_CodeCoverage::applyListsFilter ( ) + * @covers PHP_CodeCoverage::start + * @covers PHP_CodeCoverage::stop + * @covers PHP_CodeCoverage::append + * @covers PHP_CodeCoverage::applyListsFilter * @covers PHP_CodeCoverage::initializeFilesThatAreSeenTheFirstTime * @covers PHP_CodeCoverage::applyCoversAnnotationFilter * @covers PHP_CodeCoverage::getTests @@ -399,6 +396,66 @@ public function testTwoCoversDefaultClassAnnoationsAreNotAllowed() ); } + /** + * @covers PHP_CodeCoverage::getLinesToBeCovered + */ + public function testFunctionParenthesesAreAllowed() + { + $this->assertSame( + array(TEST_FILES_PATH . 'CoveredFunction.php' => range(2, 4)), + $this->getLinesToBeCovered->invoke( + $this->coverage, + 'CoverageFunctionParenthesesTest', + 'testSomething' + ) + ); + } + + /** + * @covers PHP_CodeCoverage::getLinesToBeCovered + */ + public function testFunctionParenthesesAreAllowedWithWhitespace() + { + $this->assertSame( + array(TEST_FILES_PATH . 'CoveredFunction.php' => range(2, 4)), + $this->getLinesToBeCovered->invoke( + $this->coverage, + 'CoverageFunctionParenthesesWhitespaceTest', + 'testSomething' + ) + ); + } + + /** + * @covers PHP_CodeCoverage::getLinesToBeCovered + */ + public function testMethodParenthesesAreAllowed() + { + $this->assertSame( + array(TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35)), + $this->getLinesToBeCovered->invoke( + $this->coverage, + 'CoverageMethodParenthesesTest', + 'testSomething' + ) + ); + } + + /** + * @covers PHP_CodeCoverage::getLinesToBeCovered + */ + public function testMethodParenthesesAreAllowedWithWhitespace() + { + $this->assertSame( + array(TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35)), + $this->getLinesToBeCovered->invoke( + $this->coverage, + 'CoverageMethodParenthesesWhitespaceTest', + 'testSomething' + ) + ); + } + public function getLinesToBeCoveredProvider() { return array( diff --git a/core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageFunctionParenthesesTest.php b/core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageFunctionParenthesesTest.php new file mode 100644 index 000000000000..33b5fe3de5be --- /dev/null +++ b/core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageFunctionParenthesesTest.php @@ -0,0 +1,11 @@ +<?php +class CoverageFunctionParenthesesTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers ::globalFunction() + */ + public function testSomething() + { + globalFunction(); + } +} diff --git a/core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageFunctionParenthesesWhitespaceTest.php b/core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageFunctionParenthesesWhitespaceTest.php new file mode 100644 index 000000000000..d7f7848b068c --- /dev/null +++ b/core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageFunctionParenthesesWhitespaceTest.php @@ -0,0 +1,11 @@ +<?php +class CoverageFunctionParenthesesWhitespaceTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers ::globalFunction ( ) + */ + public function testSomething() + { + globalFunction(); + } +} diff --git a/core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodParenthesesTest.php b/core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodParenthesesTest.php new file mode 100644 index 000000000000..422300457a18 --- /dev/null +++ b/core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodParenthesesTest.php @@ -0,0 +1,12 @@ +<?php +class CoverageMethodParenthesesTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers CoveredClass::publicMethod() + */ + public function testSomething() + { + $o = new CoveredClass; + $o->publicMethod(); + } +} diff --git a/core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodParenthesesWhitespaceTest.php b/core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodParenthesesWhitespaceTest.php new file mode 100644 index 000000000000..7f67f4b358ca --- /dev/null +++ b/core/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodParenthesesWhitespaceTest.php @@ -0,0 +1,12 @@ +<?php +class CoverageMethodParenthesesWhitespaceTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers CoveredClass::publicMethod ( ) + */ + public function testSomething() + { + $o = new CoveredClass; + $o->publicMethod(); + } +} diff --git a/core/vendor/phpunit/php-code-coverage/Tests/_files/source_with_oneline_annotations.php b/core/vendor/phpunit/php-code-coverage/Tests/_files/source_with_oneline_annotations.php index 358df96973be..327122e5a229 100644 --- a/core/vendor/phpunit/php-code-coverage/Tests/_files/source_with_oneline_annotations.php +++ b/core/vendor/phpunit/php-code-coverage/Tests/_files/source_with_oneline_annotations.php @@ -11,3 +11,25 @@ public function bar() { } } + +function baz() +{ + // a one-line comment + print '*'; // a one-line comment + + /* a one-line comment */ + print '*'; /* a one-line comment */ + + /* a one-line comment + */ + print '*'; /* a one-line comment + */ + + print '*'; // @codeCoverageIgnore + + print '*'; // @codeCoverageIgnoreStart + print '*'; + print '*'; // @codeCoverageIgnoreEnd + + print '*'; +} diff --git a/core/vendor/phpunit/php-code-coverage/composer.json b/core/vendor/phpunit/php-code-coverage/composer.json index 1a4ebe1b095f..201b14968a70 100644 --- a/core/vendor/phpunit/php-code-coverage/composer.json +++ b/core/vendor/phpunit/php-code-coverage/composer.json @@ -26,6 +26,9 @@ "phpunit/php-token-stream": ">=1.1.3@stable", "phpunit/php-text-template": ">=1.1.1@stable" }, + "require-dev": { + "phpunit/phpunit": "3.7.*" + }, "suggest": { "ext-dom": "*", "ext-xdebug": ">=2.0.5" diff --git a/core/vendor/phpunit/php-code-coverage/package.xml b/core/vendor/phpunit/php-code-coverage/package.xml index a4d7e9811823..8b256332930a 100644 --- a/core/vendor/phpunit/php-code-coverage/package.xml +++ b/core/vendor/phpunit/php-code-coverage/package.xml @@ -17,10 +17,10 @@ <email>sb@sebastian-bergmann.de</email> <active>yes</active> </lead> - <date>2013-02-26</date> + <date>2013-05-23</date> <version> - <release>1.2.9</release> - <api>1.2.0</api> + <release>1.2.11</release> + <api>1.2.11</api> </version> <stability> <release>stable</release> diff --git a/core/vendor/phpunit/phpunit/.gitignore b/core/vendor/phpunit/phpunit/.gitignore index c9cf08f6b14b..2aa9c32b2833 100644 --- a/core/vendor/phpunit/phpunit/.gitignore +++ b/core/vendor/phpunit/phpunit/.gitignore @@ -11,6 +11,8 @@ Tests/TextUI/*.exp Tests/TextUI/*.log Tests/TextUI/*.out Tests/TextUI/*.php +/vendor +/composer.lock phpunit.xml cache.properties .idea diff --git a/core/vendor/phpunit/phpunit/ChangeLog.md b/core/vendor/phpunit/phpunit/ChangeLog.md index e0cb167f5ae9..d1390055cae7 100644 --- a/core/vendor/phpunit/phpunit/ChangeLog.md +++ b/core/vendor/phpunit/phpunit/ChangeLog.md @@ -3,6 +3,23 @@ PHPUnit 3.7 This is the list of changes for the PHPUnit 3.7 release series. +PHPUnit 3.7.21 +-------------- + +* Fixed #277: Account for `auto-globals-jit` when setting `$_ENV` and `$_SERVER` variables in the xml config. +* Fixed #924: PHPUnit depends on packages that broke backwards compatability. + +PHPUnit 3.7.20 +-------------- + +* Fixed #883: Stand-alone functions `logicalAnd()`, `logicalOr()`, and `logicalXor()` did not work. +* Fixed #889: Suppress `open_basedir` warnings while searching for the composer autoloader. +* Fixed #890: Correctly parse single-line @expectedException annotations. +* Fixed #891: Better messages when JSON-related assertions receive invalid JSON. +* Fixed #896: Use the proper `toString()` method inside `PHPUnit_Framework_TestFailure::toString()`. +* Fixed #902: Allow symfony/yaml >=2.0,<3.0 +* Fixed #908: Don't rely on composer to set up the `include_path` for `ErrorHandler.php`. + PHPUnit 3.7.19 -------------- diff --git a/core/vendor/phpunit/phpunit/PHPUnit/Autoload.php b/core/vendor/phpunit/phpunit/PHPUnit/Autoload.php index 4cd2196b716a..f1bd633a26b2 100644 --- a/core/vendor/phpunit/phpunit/PHPUnit/Autoload.php +++ b/core/vendor/phpunit/phpunit/PHPUnit/Autoload.php @@ -52,8 +52,8 @@ ); foreach ($paths as $path) { - if (is_dir($path . '/composer') && - is_file($path . '/autoload.php')) { + if (@is_dir($path . '/composer') && + @is_file($path . '/autoload.php')) { require_once $path . '/autoload.php'; define('PHPUNIT_COMPOSER_INSTALL', $path . '/autoload.php'); @@ -118,6 +118,7 @@ function ($class) 'phpunit_framework_constraint_isfalse' => '/Framework/Constraint/IsFalse.php', 'phpunit_framework_constraint_isidentical' => '/Framework/Constraint/IsIdentical.php', 'phpunit_framework_constraint_isinstanceof' => '/Framework/Constraint/IsInstanceOf.php', + 'phpunit_framework_constraint_isjson' => '/Framework/Constraint/IsJson.php', 'phpunit_framework_constraint_isnull' => '/Framework/Constraint/IsNull.php', 'phpunit_framework_constraint_istrue' => '/Framework/Constraint/IsTrue.php', 'phpunit_framework_constraint_istype' => '/Framework/Constraint/IsType.php', diff --git a/core/vendor/phpunit/phpunit/PHPUnit/Autoload.php.in b/core/vendor/phpunit/phpunit/PHPUnit/Autoload.php.in index e5059f3f27fd..2072e7678b8f 100644 --- a/core/vendor/phpunit/phpunit/PHPUnit/Autoload.php.in +++ b/core/vendor/phpunit/phpunit/PHPUnit/Autoload.php.in @@ -52,8 +52,8 @@ $paths = array( ); foreach ($paths as $path) { - if (is_dir($path . '/composer') && - is_file($path . '/autoload.php')) { + if (@is_dir($path . '/composer') && + @is_file($path . '/autoload.php')) { require_once $path . '/autoload.php'; define('PHPUNIT_COMPOSER_INSTALL', $path . '/autoload.php'); diff --git a/core/vendor/phpunit/phpunit/PHPUnit/Framework/Assert.php b/core/vendor/phpunit/phpunit/PHPUnit/Framework/Assert.php index 929a3ca8664c..e38839d8358e 100644 --- a/core/vendor/phpunit/phpunit/PHPUnit/Framework/Assert.php +++ b/core/vendor/phpunit/phpunit/PHPUnit/Framework/Assert.php @@ -2134,6 +2134,22 @@ public static function assertThat($value, PHPUnit_Framework_Constraint $constrai $constraint->evaluate($value, $message); } + /** + * Asserts that a string is a valid JSON string. + * + * @param string $filename + * @param string $message + * @since Method available since Release 3.7.20 + */ + public static function assertJson($expectedJson, $message = '') + { + if (!is_string($expectedJson)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + self::assertThat($expectedJson, self::isJson(), $message); + } + /** * Asserts that two given JSON encoded objects or arrays are equal. * @@ -2143,23 +2159,12 @@ public static function assertThat($value, PHPUnit_Framework_Constraint $constrai */ public static function assertJsonStringEqualsJsonString($expectedJson, $actualJson, $message = '') { - $expected = json_decode($expectedJson); - if ($jsonError = json_last_error()) { - $message .= - PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::determineJsonError( - $jsonError, - PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::translateTypeToPrefix('expected') - ); - } + self::assertJson($expectedJson, $message); + self::assertJson($actualJson, $message); + $expected = json_decode($expectedJson); $actual = json_decode($actualJson); - if ($jsonError = json_last_error()) { - $message .= - PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::determineJsonError( - $jsonError, - PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::translateTypeToPrefix('actual') - ); - } + return self::assertEquals($expected, $actual, $message); } @@ -2172,23 +2177,11 @@ public static function assertJsonStringEqualsJsonString($expectedJson, $actualJs */ public static function assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $message = '') { - $expected = json_decode($expectedJson); - if ($jsonError = json_last_error()) { - $message .= - PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::determineJsonError( - $jsonError, - PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::translateTypeToPrefix('expected') - ); - } + self::assertJson($expectedJson, $message); + self::assertJson($actualJson, $message); + $expected = json_decode($expectedJson); $actual = json_decode($actualJson); - if ($jsonError = json_last_error()) { - $message .= - PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::determineJsonError( - $jsonError, - PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::translateTypeToPrefix('actual') - ); - } self::assertNotEquals($expected, $actual, $message); } @@ -2203,14 +2196,14 @@ public static function assertJsonStringNotEqualsJsonString($expectedJson, $actua public static function assertJsonStringEqualsJsonFile($expectedFile, $actualJson, $message = '') { self::assertFileExists($expectedFile, $message); + $expectedJson = file_get_contents($expectedFile); - if (!is_string($actualJson)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } + self::assertJson($expectedJson, $message); + self::assertJson($actualJson, $message); // call constraint $constraint = new PHPUnit_Framework_Constraint_JsonMatches( - file_get_contents($expectedFile) + $expectedJson ); self::assertThat($actualJson, $constraint, $message); @@ -2226,14 +2219,14 @@ public static function assertJsonStringEqualsJsonFile($expectedFile, $actualJson public static function assertJsonStringNotEqualsJsonFile($expectedFile, $actualJson, $message = '') { self::assertFileExists($expectedFile, $message); + $expectedJson = file_get_contents($expectedFile); - if (!is_string($actualJson)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } + self::assertJson($expectedJson, $message); + self::assertJson($actualJson, $message); // call constraint $constraint = new PHPUnit_Framework_Constraint_JsonMatches( - file_get_contents($expectedFile) + $expectedJson ); self::assertThat($actualJson, new PHPUnit_Framework_Constraint_Not($constraint), $message); @@ -2254,9 +2247,12 @@ public static function assertJsonFileNotEqualsJsonFile($expectedFile, $actualFil $actualJson = file_get_contents($actualFile); $expectedJson = file_get_contents($expectedFile); + self::assertJson($expectedJson, $message); + self::assertJson($actualJson, $message); + // call constraint $constraintExpected = new PHPUnit_Framework_Constraint_JsonMatches( - file_get_contents($expectedFile) + $expectedJson ); $constraintActual = new PHPUnit_Framework_Constraint_JsonMatches($actualJson); @@ -2280,9 +2276,12 @@ public static function assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $actualJson = file_get_contents($actualFile); $expectedJson = file_get_contents($expectedFile); + self::assertJson($expectedJson, $message); + self::assertJson($actualJson, $message); + // call constraint $constraintExpected = new PHPUnit_Framework_Constraint_JsonMatches( - file_get_contents($expectedFile) + $expectedJson ); $constraintActual = new PHPUnit_Framework_Constraint_JsonMatches($actualJson); @@ -2395,6 +2394,17 @@ public static function isFalse() return new PHPUnit_Framework_Constraint_IsFalse; } + /** + * Returns a PHPUnit_Framework_Constraint_IsJson matcher object. + * + * @return PHPUnit_Framework_Constraint_IsJson + * @since Method available since Release 3.7.20 + */ + public static function isJson() + { + return new PHPUnit_Framework_Constraint_IsJson; + } + /** * Returns a PHPUnit_Framework_Constraint_IsNull matcher object. * @@ -2524,6 +2534,7 @@ public static function isEmpty() { return new PHPUnit_Framework_Constraint_IsEmpty; } + /** * Returns a PHPUnit_Framework_Constraint_FileExists matcher object. * diff --git a/core/vendor/phpunit/phpunit/PHPUnit/Framework/Assert/Functions.php b/core/vendor/phpunit/phpunit/PHPUnit/Framework/Assert/Functions.php index 6ec0c4291f82..27d13b59464d 100644 --- a/core/vendor/phpunit/phpunit/PHPUnit/Framework/Assert/Functions.php +++ b/core/vendor/phpunit/phpunit/PHPUnit/Framework/Assert/Functions.php @@ -52,7 +52,10 @@ */ function any() { - return PHPUnit_Framework_TestCase::any(); + return call_user_func_array( + 'PHPUnit_Framework_TestCase::any', + func_get_args() + ); } /** @@ -63,7 +66,10 @@ function any() */ function anything() { - return PHPUnit_Framework_Assert::anything(); + return call_user_func_array( + 'PHPUnit_Framework_Assert::anything', + func_get_args() + ); } /** @@ -75,33 +81,42 @@ function anything() */ function arrayHasKey($key) { - return PHPUnit_Framework_Assert::arrayHasKey($key); + return call_user_func_array( + 'PHPUnit_Framework_Assert::arrayHasKey', + func_get_args() + ); } /** * Asserts that an array has a specified key. * * @param mixed $key - * @param array $array + * @param array|ArrayAccess $array * @param string $message * @since Method available since Release 3.0.0 */ -function assertArrayHasKey($key, array $array, $message = '') +function assertArrayHasKey($key, $array, $message = '') { - return PHPUnit_Framework_Assert::assertArrayHasKey($key, $array, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertArrayHasKey', + func_get_args() + ); } /** * Asserts that an array does not have a specified key. * * @param mixed $key - * @param array $array + * @param array|ArrayAccess $array * @param string $message * @since Method available since Release 3.0.0 */ -function assertArrayNotHasKey($key, array $array, $message = '') +function assertArrayNotHasKey($key, $array, $message = '') { - return PHPUnit_Framework_Assert::assertArrayNotHasKey($key, $array, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertArrayNotHasKey', + func_get_args() + ); } /** @@ -118,7 +133,10 @@ function assertArrayNotHasKey($key, array $array, $message = '') */ function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) { - return PHPUnit_Framework_Assert::assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message, $ignoreCase, $checkForObjectIdentity); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeContains', + func_get_args() + ); } /** @@ -134,7 +152,10 @@ function assertAttributeContains($needle, $haystackAttributeName, $haystackClass */ function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = NULL, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeContainsOnly', + func_get_args() + ); } /** @@ -149,7 +170,10 @@ function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackCla */ function assertAttributeCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeCount', + func_get_args() + ); } /** @@ -163,7 +187,10 @@ function assertAttributeCount($expectedCount, $haystackAttributeName, $haystackC */ function assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeEmpty', + func_get_args() + ); } /** @@ -180,7 +207,10 @@ function assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $m */ function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) { - return PHPUnit_Framework_Assert::assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeEquals', + func_get_args() + ); } /** @@ -194,7 +224,10 @@ function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrOb */ function assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeGreaterThan', + func_get_args() + ); } /** @@ -208,7 +241,10 @@ function assertAttributeGreaterThan($expected, $actualAttributeName, $actualClas */ function assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeGreaterThanOrEqual', + func_get_args() + ); } /** @@ -222,7 +258,10 @@ function assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $act */ function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeInstanceOf', + func_get_args() + ); } /** @@ -236,7 +275,10 @@ function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $m */ function assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeInternalType($expected, $attributeName, $classOrObject, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeInternalType', + func_get_args() + ); } /** @@ -250,7 +292,10 @@ function assertAttributeInternalType($expected, $attributeName, $classOrObject, */ function assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeLessThan', + func_get_args() + ); } /** @@ -264,7 +309,10 @@ function assertAttributeLessThan($expected, $actualAttributeName, $actualClassOr */ function assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeLessThanOrEqual', + func_get_args() + ); } /** @@ -281,7 +329,10 @@ function assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actual */ function assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) { - return PHPUnit_Framework_Assert::assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message, $ignoreCase, $checkForObjectIdentity); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeNotContains', + func_get_args() + ); } /** @@ -298,7 +349,10 @@ function assertAttributeNotContains($needle, $haystackAttributeName, $haystackCl */ function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = NULL, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeNotContainsOnly', + func_get_args() + ); } /** @@ -313,7 +367,10 @@ function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystack */ function assertAttributeNotCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeNotCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeNotCount', + func_get_args() + ); } /** @@ -327,7 +384,10 @@ function assertAttributeNotCount($expectedCount, $haystackAttributeName, $haysta */ function assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeNotEmpty', + func_get_args() + ); } /** @@ -344,7 +404,10 @@ function assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, */ function assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) { - return PHPUnit_Framework_Assert::assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeNotEquals', + func_get_args() + ); } /** @@ -358,7 +421,10 @@ function assertAttributeNotEquals($expected, $actualAttributeName, $actualClassO */ function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeNotInstanceOf', + func_get_args() + ); } /** @@ -372,7 +438,10 @@ function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, */ function assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeNotInternalType', + func_get_args() + ); } /** @@ -386,7 +455,10 @@ function assertAttributeNotInternalType($expected, $attributeName, $classOrObjec */ function assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeNotSame', + func_get_args() + ); } /** @@ -400,7 +472,10 @@ function assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrO */ function assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') { - return PHPUnit_Framework_Assert::assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertAttributeSame', + func_get_args() + ); } /** @@ -413,7 +488,10 @@ function assertAttributeSame($expected, $actualAttributeName, $actualClassOrObje */ function assertClassHasAttribute($attributeName, $className, $message = '') { - return PHPUnit_Framework_Assert::assertClassHasAttribute($attributeName, $className, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertClassHasAttribute', + func_get_args() + ); } /** @@ -426,7 +504,10 @@ function assertClassHasAttribute($attributeName, $className, $message = '') */ function assertClassHasStaticAttribute($attributeName, $className, $message = '') { - return PHPUnit_Framework_Assert::assertClassHasStaticAttribute($attributeName, $className, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertClassHasStaticAttribute', + func_get_args() + ); } /** @@ -439,7 +520,10 @@ function assertClassHasStaticAttribute($attributeName, $className, $message = '' */ function assertClassNotHasAttribute($attributeName, $className, $message = '') { - return PHPUnit_Framework_Assert::assertClassNotHasAttribute($attributeName, $className, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertClassNotHasAttribute', + func_get_args() + ); } /** @@ -452,7 +536,10 @@ function assertClassNotHasAttribute($attributeName, $className, $message = '') */ function assertClassNotHasStaticAttribute($attributeName, $className, $message = '') { - return PHPUnit_Framework_Assert::assertClassNotHasStaticAttribute($attributeName, $className, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertClassNotHasStaticAttribute', + func_get_args() + ); } /** @@ -467,7 +554,10 @@ function assertClassNotHasStaticAttribute($attributeName, $className, $message = */ function assertContains($needle, $haystack, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) { - return PHPUnit_Framework_Assert::assertContains($needle, $haystack, $message, $ignoreCase, $checkForObjectIdentity); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertContains', + func_get_args() + ); } /** @@ -481,7 +571,25 @@ function assertContains($needle, $haystack, $message = '', $ignoreCase = FALSE, */ function assertContainsOnly($type, $haystack, $isNativeType = NULL, $message = '') { - return PHPUnit_Framework_Assert::assertContainsOnly($type, $haystack, $isNativeType, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertContainsOnly', + func_get_args() + ); +} + +/** + * Asserts that a haystack contains only instances of a given classname + * + * @param string $classname + * @param array|Traversable $haystack + * @param string $message + */ +function assertContainsOnlyInstancesOf($classname, $haystack, $message = '') +{ + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertContainsOnlyInstancesOf', + func_get_args() + ); } /** @@ -493,7 +601,10 @@ function assertContainsOnly($type, $haystack, $isNativeType = NULL, $message = ' */ function assertCount($expectedCount, $haystack, $message = '') { - return PHPUnit_Framework_Assert::assertCount($expectedCount, $haystack, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertCount', + func_get_args() + ); } /** @@ -505,7 +616,10 @@ function assertCount($expectedCount, $haystack, $message = '') */ function assertEmpty($actual, $message = '') { - return PHPUnit_Framework_Assert::assertEmpty($actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertEmpty', + func_get_args() + ); } /** @@ -520,7 +634,10 @@ function assertEmpty($actual, $message = '') */ function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, $checkAttributes = FALSE, $message = '') { - return PHPUnit_Framework_Assert::assertEqualXMLStructure($expectedElement, $actualElement, $checkAttributes, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertEqualXMLStructure', + func_get_args() + ); } /** @@ -536,7 +653,10 @@ function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actual */ function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) { - return PHPUnit_Framework_Assert::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertEquals', + func_get_args() + ); } /** @@ -548,7 +668,10 @@ function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = */ function assertFalse($condition, $message = '') { - return PHPUnit_Framework_Assert::assertFalse($condition, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertFalse', + func_get_args() + ); } /** @@ -564,7 +687,10 @@ function assertFalse($condition, $message = '') */ function assertFileEquals($expected, $actual, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) { - return PHPUnit_Framework_Assert::assertFileEquals($expected, $actual, $message, $canonicalize, $ignoreCase); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertFileEquals', + func_get_args() + ); } /** @@ -576,7 +702,10 @@ function assertFileEquals($expected, $actual, $message = '', $canonicalize = FAL */ function assertFileExists($filename, $message = '') { - return PHPUnit_Framework_Assert::assertFileExists($filename, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertFileExists', + func_get_args() + ); } /** @@ -592,7 +721,10 @@ function assertFileExists($filename, $message = '') */ function assertFileNotEquals($expected, $actual, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) { - return PHPUnit_Framework_Assert::assertFileNotEquals($expected, $actual, $message, $canonicalize, $ignoreCase); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertFileNotEquals', + func_get_args() + ); } /** @@ -604,7 +736,10 @@ function assertFileNotEquals($expected, $actual, $message = '', $canonicalize = */ function assertFileNotExists($filename, $message = '') { - return PHPUnit_Framework_Assert::assertFileNotExists($filename, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertFileNotExists', + func_get_args() + ); } /** @@ -617,7 +752,10 @@ function assertFileNotExists($filename, $message = '') */ function assertGreaterThan($expected, $actual, $message = '') { - return PHPUnit_Framework_Assert::assertGreaterThan($expected, $actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertGreaterThan', + func_get_args() + ); } /** @@ -630,7 +768,10 @@ function assertGreaterThan($expected, $actual, $message = '') */ function assertGreaterThanOrEqual($expected, $actual, $message = '') { - return PHPUnit_Framework_Assert::assertGreaterThanOrEqual($expected, $actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertGreaterThanOrEqual', + func_get_args() + ); } /** @@ -643,7 +784,10 @@ function assertGreaterThanOrEqual($expected, $actual, $message = '') */ function assertInstanceOf($expected, $actual, $message = '') { - return PHPUnit_Framework_Assert::assertInstanceOf($expected, $actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertInstanceOf', + func_get_args() + ); } /** @@ -656,33 +800,55 @@ function assertInstanceOf($expected, $actual, $message = '') */ function assertInternalType($expected, $actual, $message = '') { - return PHPUnit_Framework_Assert::assertInternalType($expected, $actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertInternalType', + func_get_args() + ); } /** - * Asserts that two given JSON encoded objects or arrays are equal. + * Asserts that a string is a valid JSON string. * - * @param string $expectedJson - * @param string $actualJson - * @param string $message - * @since Method available since Release 3.7.0 + * @param string $filename + * @param string $message + * @since Method available since Release 3.7.20 */ -function assertJsonStringEqualsJsonString($expectedJson, $actualJson, $message = '') +function assertJson($expectedJson, $message = '') { - return PHPUnit_Framework_Assert::assertJsonStringEqualsJsonString($expectedJson, $actualJson, $message = ''); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertJson', + func_get_args() + ); } /** - * Asserts that two given JSON encoded objects or arrays are not equal. + * Asserts that two JSON files are equal. * - * @param string $expectedJson - * @param string $actualJson - * @param string $message - * @since Method available since Release 3.7.0 + * @param string $expectedFile + * @param string $actualFile + * @param string $message */ -function assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $message = '') +function assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $message = '') +{ + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertJsonFileEqualsJsonFile', + func_get_args() + ); +} + +/** + * Asserts that two JSON files are not equal. + * + * @param string $expectedFile + * @param string $actualFile + * @param string $message + */ +function assertJsonFileNotEqualsJsonFile($expectedFile, $actualFile, $message = '') { - return PHPUnit_Framework_Assert::assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $message = ''); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertJsonFileNotEqualsJsonFile', + func_get_args() + ); } /** @@ -691,50 +857,58 @@ function assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $messag * @param string $expectedFile * @param string $actualJson * @param string $message - * @since Method available since Release 3.7.0 */ function assertJsonStringEqualsJsonFile($expectedFile, $actualJson, $message = '') { - return PHPUnit_Framework_Assert::assertJsonStringEqualsJsonFile($expectedFile, $actualJson, $message = ''); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertJsonStringEqualsJsonFile', + func_get_args() + ); } /** - * Asserts that the generated JSON encoded object and the content of the given file are not equal. + * Asserts that two given JSON encoded objects or arrays are equal. * - * @param string $expectedFile + * @param string $expectedJson * @param string $actualJson * @param string $message - * @since Method available since Release 3.7.0 */ -function assertJsonStringNotEqualsJsonFile($expectedFile, $actualJson, $message = '') +function assertJsonStringEqualsJsonString($expectedJson, $actualJson, $message = '') { - return PHPUnit_Framework_Assert::assertJsonStringNotEqualsJsonFile($expectedFile, $actualJson, $message = ''); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertJsonStringEqualsJsonString', + func_get_args() + ); } /** - * Asserts that two JSON files are not equal. + * Asserts that the generated JSON encoded object and the content of the given file are not equal. * - * @param string $expectedFile - * @param string $actualFile - * @param string $message - * @since Method available since Release 3.7.0 + * @param string $expectedFile + * @param string $actualJson + * @param string $message */ -function assertJsonFileNotEqualsJsonFile($expectedFile, $actualFile, $message = '') +function assertJsonStringNotEqualsJsonFile($expectedFile, $actualJson, $message = '') { - return PHPUnit_Framework_Assert::assertJsonFileNotEqualsJsonFile($expectedFile, $actualFile, $message = ''); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertJsonStringNotEqualsJsonFile', + func_get_args() + ); } /** - * Asserts that two JSON files are equal. + * Asserts that two given JSON encoded objects or arrays are not equal. * - * @param string $expectedFile - * @param string $actualFile - * @param string $message - * @since Method available since Release 3.7.0 + * @param string $expectedJson + * @param string $actualJson + * @param string $message */ -function assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $message = '') +function assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $message = '') { - return PHPUnit_Framework_Assert::assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $message = ''); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertJsonStringNotEqualsJsonString', + func_get_args() + ); } /** @@ -747,7 +921,10 @@ function assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $message = '') */ function assertLessThan($expected, $actual, $message = '') { - return PHPUnit_Framework_Assert::assertLessThan($expected, $actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertLessThan', + func_get_args() + ); } /** @@ -760,7 +937,10 @@ function assertLessThan($expected, $actual, $message = '') */ function assertLessThanOrEqual($expected, $actual, $message = '') { - return PHPUnit_Framework_Assert::assertLessThanOrEqual($expected, $actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertLessThanOrEqual', + func_get_args() + ); } /** @@ -775,7 +955,10 @@ function assertLessThanOrEqual($expected, $actual, $message = '') */ function assertNotContains($needle, $haystack, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) { - return PHPUnit_Framework_Assert::assertNotContains($needle, $haystack, $message, $ignoreCase, $checkForObjectIdentity); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertNotContains', + func_get_args() + ); } /** @@ -789,7 +972,10 @@ function assertNotContains($needle, $haystack, $message = '', $ignoreCase = FALS */ function assertNotContainsOnly($type, $haystack, $isNativeType = NULL, $message = '') { - return PHPUnit_Framework_Assert::assertNotContainsOnly($type, $haystack, $isNativeType, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertNotContainsOnly', + func_get_args() + ); } /** @@ -801,7 +987,10 @@ function assertNotContainsOnly($type, $haystack, $isNativeType = NULL, $message */ function assertNotCount($expectedCount, $haystack, $message = '') { - return PHPUnit_Framework_Assert::assertNotCount($expectedCount, $haystack, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertNotCount', + func_get_args() + ); } /** @@ -813,7 +1002,10 @@ function assertNotCount($expectedCount, $haystack, $message = '') */ function assertNotEmpty($actual, $message = '') { - return PHPUnit_Framework_Assert::assertNotEmpty($actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertNotEmpty', + func_get_args() + ); } /** @@ -830,7 +1022,10 @@ function assertNotEmpty($actual, $message = '') */ function assertNotEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) { - return PHPUnit_Framework_Assert::assertNotEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertNotEquals', + func_get_args() + ); } /** @@ -843,7 +1038,10 @@ function assertNotEquals($expected, $actual, $message = '', $delta = 0, $maxDept */ function assertNotInstanceOf($expected, $actual, $message = '') { - return PHPUnit_Framework_Assert::assertNotInstanceOf($expected, $actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertNotInstanceOf', + func_get_args() + ); } /** @@ -856,7 +1054,10 @@ function assertNotInstanceOf($expected, $actual, $message = '') */ function assertNotInternalType($expected, $actual, $message = '') { - return PHPUnit_Framework_Assert::assertNotInternalType($expected, $actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertNotInternalType', + func_get_args() + ); } /** @@ -867,7 +1068,10 @@ function assertNotInternalType($expected, $actual, $message = '') */ function assertNotNull($actual, $message = '') { - return PHPUnit_Framework_Assert::assertNotNull($actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertNotNull', + func_get_args() + ); } /** @@ -880,7 +1084,10 @@ function assertNotNull($actual, $message = '') */ function assertNotRegExp($pattern, $string, $message = '') { - return PHPUnit_Framework_Assert::assertNotRegExp($pattern, $string, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertNotRegExp', + func_get_args() + ); } /** @@ -894,20 +1101,26 @@ function assertNotRegExp($pattern, $string, $message = '') */ function assertNotSame($expected, $actual, $message = '') { - return PHPUnit_Framework_Assert::assertNotSame($expected, $actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertNotSame', + func_get_args() + ); } /** * Assert that the size of two arrays (or `Countable` or `Iterator` objects) * is not the same. * - * @param integer $expected - * @param mixed $actual - * @param string $message + * @param array|Countable|Iterator $expected + * @param array|Countable|Iterator $actual + * @param string $message */ -function assertNotSameSize($expectedCount, $haystack, $message = '') +function assertNotSameSize($expected, $actual, $message = '') { - return PHPUnit_Framework_Assert::assertNotSameSize($expectedCount, $haystack, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertNotSameSize', + func_get_args() + ); } /** @@ -926,7 +1139,10 @@ function assertNotSameSize($expectedCount, $haystack, $message = '') */ function assertNotTag($matcher, $actual, $message = '', $isHtml = TRUE) { - return PHPUnit_Framework_Assert::assertNotTag($matcher, $actual, $message, $isHtml); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertNotTag', + func_get_args() + ); } /** @@ -937,7 +1153,10 @@ function assertNotTag($matcher, $actual, $message = '', $isHtml = TRUE) */ function assertNull($actual, $message = '') { - return PHPUnit_Framework_Assert::assertNull($actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertNull', + func_get_args() + ); } /** @@ -950,7 +1169,10 @@ function assertNull($actual, $message = '') */ function assertObjectHasAttribute($attributeName, $object, $message = '') { - return PHPUnit_Framework_Assert::assertObjectHasAttribute($attributeName, $object, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertObjectHasAttribute', + func_get_args() + ); } /** @@ -963,7 +1185,10 @@ function assertObjectHasAttribute($attributeName, $object, $message = '') */ function assertObjectNotHasAttribute($attributeName, $object, $message = '') { - return PHPUnit_Framework_Assert::assertObjectNotHasAttribute($attributeName, $object, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertObjectNotHasAttribute', + func_get_args() + ); } /** @@ -975,7 +1200,10 @@ function assertObjectNotHasAttribute($attributeName, $object, $message = '') */ function assertRegExp($pattern, $string, $message = '') { - return PHPUnit_Framework_Assert::assertRegExp($pattern, $string, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertRegExp', + func_get_args() + ); } /** @@ -989,20 +1217,26 @@ function assertRegExp($pattern, $string, $message = '') */ function assertSame($expected, $actual, $message = '') { - return PHPUnit_Framework_Assert::assertSame($expected, $actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertSame', + func_get_args() + ); } /** * Assert that the size of two arrays (or `Countable` or `Iterator` objects) * is the same. * - * @param integer $expected - * @param mixed $actual - * @param string $message + * @param array|Countable|Iterator $expected + * @param array|Countable|Iterator $actual + * @param string $message */ function assertSameSize($expected, $actual, $message = '') { - return PHPUnit_Framework_Assert::assertSameSize($expected, $actual, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertSameSize', + func_get_args() + ); } /** @@ -1031,7 +1265,10 @@ function assertSameSize($expected, $actual, $message = '') */ function assertSelectCount($selector, $count, $actual, $message = '', $isHtml = TRUE) { - return PHPUnit_Framework_Assert::assertSelectCount($selector, $count, $actual, $message, $isHtml); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertSelectCount', + func_get_args() + ); } /** @@ -1050,7 +1287,10 @@ function assertSelectCount($selector, $count, $actual, $message = '', $isHtml = */ function assertSelectEquals($selector, $content, $count, $actual, $message = '', $isHtml = TRUE) { - return PHPUnit_Framework_Assert::assertSelectEquals($selector, $content, $count, $actual, $message, $isHtml); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertSelectEquals', + func_get_args() + ); } /** @@ -1069,7 +1309,10 @@ function assertSelectEquals($selector, $content, $count, $actual, $message = '', */ function assertSelectRegExp($selector, $pattern, $count, $actual, $message = '', $isHtml = TRUE) { - return PHPUnit_Framework_Assert::assertSelectRegExp($selector, $pattern, $count, $actual, $message, $isHtml); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertSelectRegExp', + func_get_args() + ); } /** @@ -1082,7 +1325,10 @@ function assertSelectRegExp($selector, $pattern, $count, $actual, $message = '', */ function assertStringEndsNotWith($suffix, $string, $message = '') { - return PHPUnit_Framework_Assert::assertStringEndsNotWith($suffix, $string, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertStringEndsNotWith', + func_get_args() + ); } /** @@ -1095,7 +1341,10 @@ function assertStringEndsNotWith($suffix, $string, $message = '') */ function assertStringEndsWith($suffix, $string, $message = '') { - return PHPUnit_Framework_Assert::assertStringEndsWith($suffix, $string, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertStringEndsWith', + func_get_args() + ); } /** @@ -1111,7 +1360,10 @@ function assertStringEndsWith($suffix, $string, $message = '') */ function assertStringEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) { - return PHPUnit_Framework_Assert::assertStringEqualsFile($expectedFile, $actualString, $message, $canonicalize, $ignoreCase); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertStringEqualsFile', + func_get_args() + ); } /** @@ -1124,7 +1376,10 @@ function assertStringEqualsFile($expectedFile, $actualString, $message = '', $ca */ function assertStringMatchesFormat($format, $string, $message = '') { - return PHPUnit_Framework_Assert::assertStringMatchesFormat($format, $string, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertStringMatchesFormat', + func_get_args() + ); } /** @@ -1137,7 +1392,10 @@ function assertStringMatchesFormat($format, $string, $message = '') */ function assertStringMatchesFormatFile($formatFile, $string, $message = '') { - return PHPUnit_Framework_Assert::assertStringMatchesFormatFile($formatFile, $string, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertStringMatchesFormatFile', + func_get_args() + ); } /** @@ -1153,7 +1411,10 @@ function assertStringMatchesFormatFile($formatFile, $string, $message = '') */ function assertStringNotEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) { - return PHPUnit_Framework_Assert::assertStringNotEqualsFile($expectedFile, $actualString, $message, $canonicalize, $ignoreCase); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertStringNotEqualsFile', + func_get_args() + ); } /** @@ -1166,7 +1427,10 @@ function assertStringNotEqualsFile($expectedFile, $actualString, $message = '', */ function assertStringNotMatchesFormat($format, $string, $message = '') { - return PHPUnit_Framework_Assert::assertStringNotMatchesFormat($format, $string, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertStringNotMatchesFormat', + func_get_args() + ); } /** @@ -1179,7 +1443,10 @@ function assertStringNotMatchesFormat($format, $string, $message = '') */ function assertStringNotMatchesFormatFile($formatFile, $string, $message = '') { - return PHPUnit_Framework_Assert::assertStringNotMatchesFormatFile($formatFile, $string, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertStringNotMatchesFormatFile', + func_get_args() + ); } /** @@ -1192,7 +1459,10 @@ function assertStringNotMatchesFormatFile($formatFile, $string, $message = '') */ function assertStringStartsNotWith($prefix, $string, $message = '') { - return PHPUnit_Framework_Assert::assertStringStartsNotWith($prefix, $string, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertStringStartsNotWith', + func_get_args() + ); } /** @@ -1205,7 +1475,10 @@ function assertStringStartsNotWith($prefix, $string, $message = '') */ function assertStringStartsWith($prefix, $string, $message = '') { - return PHPUnit_Framework_Assert::assertStringStartsWith($prefix, $string, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertStringStartsWith', + func_get_args() + ); } /** @@ -1347,7 +1620,10 @@ function assertStringStartsWith($prefix, $string, $message = '') */ function assertTag($matcher, $actual, $message = '', $isHtml = TRUE) { - return PHPUnit_Framework_Assert::assertTag($matcher, $actual, $message, $isHtml); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertTag', + func_get_args() + ); } /** @@ -1360,7 +1636,10 @@ function assertTag($matcher, $actual, $message = '', $isHtml = TRUE) */ function assertThat($value, PHPUnit_Framework_Constraint $constraint, $message = '') { - return PHPUnit_Framework_Assert::assertThat($value, $constraint, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertThat', + func_get_args() + ); } /** @@ -1372,7 +1651,10 @@ function assertThat($value, PHPUnit_Framework_Constraint $constraint, $message = */ function assertTrue($condition, $message = '') { - return PHPUnit_Framework_Assert::assertTrue($condition, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertTrue', + func_get_args() + ); } /** @@ -1385,7 +1667,10 @@ function assertTrue($condition, $message = '') */ function assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = '') { - return PHPUnit_Framework_Assert::assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertXmlFileEqualsXmlFile', + func_get_args() + ); } /** @@ -1398,7 +1683,10 @@ function assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = '') */ function assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = '') { - return PHPUnit_Framework_Assert::assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertXmlFileNotEqualsXmlFile', + func_get_args() + ); } /** @@ -1411,7 +1699,10 @@ function assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = '' */ function assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message = '') { - return PHPUnit_Framework_Assert::assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertXmlStringEqualsXmlFile', + func_get_args() + ); } /** @@ -1424,7 +1715,10 @@ function assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message = '') */ function assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = '') { - return PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString', + func_get_args() + ); } /** @@ -1437,7 +1731,10 @@ function assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = '') */ function assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = '') { - return PHPUnit_Framework_Assert::assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertXmlStringNotEqualsXmlFile', + func_get_args() + ); } /** @@ -1450,7 +1747,10 @@ function assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = ' */ function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = '') { - return PHPUnit_Framework_Assert::assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message); + return call_user_func_array( + 'PHPUnit_Framework_Assert::assertXmlStringNotEqualsXmlString', + func_get_args() + ); } /** @@ -1463,7 +1763,10 @@ function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = */ function at($index) { - return PHPUnit_Framework_TestCase::at($index); + return call_user_func_array( + 'PHPUnit_Framework_TestCase::at', + func_get_args() + ); } /** @@ -1475,7 +1778,10 @@ function at($index) */ function atLeastOnce() { - return PHPUnit_Framework_TestCase::atLeastOnce(); + return call_user_func_array( + 'PHPUnit_Framework_TestCase::atLeastOnce', + func_get_args() + ); } /** @@ -1488,7 +1794,10 @@ function atLeastOnce() */ function attribute(PHPUnit_Framework_Constraint $constraint, $attributeName) { - return PHPUnit_Framework_Assert::attribute($constraint, $attributeName); + return call_user_func_array( + 'PHPUnit_Framework_Assert::attribute', + func_get_args() + ); } /** @@ -1507,7 +1816,24 @@ function attribute(PHPUnit_Framework_Constraint $constraint, $attributeName) */ function attributeEqualTo($attributeName, $value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) { - return PHPUnit_Framework_Assert::attributeEqualTo($attributeName, $value, $delta, $maxDepth, $canonicalize, $ignoreCase); + return call_user_func_array( + 'PHPUnit_Framework_Assert::attributeEqualTo', + func_get_args() + ); +} + +/** + * Returns a PHPUnit_Framework_Constraint_Callback matcher object. + * + * @param callable $callback + * @return PHPUnit_Framework_Constraint_Callback + */ +function callback($callback) +{ + return call_user_func_array( + 'PHPUnit_Framework_Assert::callback', + func_get_args() + ); } /** @@ -1519,7 +1845,10 @@ function attributeEqualTo($attributeName, $value, $delta = 0, $maxDepth = 10, $c */ function classHasAttribute($attributeName) { - return PHPUnit_Framework_Assert::classHasAttribute($attributeName); + return call_user_func_array( + 'PHPUnit_Framework_Assert::classHasAttribute', + func_get_args() + ); } /** @@ -1532,7 +1861,10 @@ function classHasAttribute($attributeName) */ function classHasStaticAttribute($attributeName) { - return PHPUnit_Framework_Assert::classHasStaticAttribute($attributeName); + return call_user_func_array( + 'PHPUnit_Framework_Assert::classHasStaticAttribute', + func_get_args() + ); } /** @@ -1546,7 +1878,10 @@ function classHasStaticAttribute($attributeName) */ function contains($value, $checkForObjectIdentity = TRUE) { - return PHPUnit_Framework_Assert::contains($value, $checkForObjectIdentity); + return call_user_func_array( + 'PHPUnit_Framework_Assert::contains', + func_get_args() + ); } /** @@ -1559,7 +1894,25 @@ function contains($value, $checkForObjectIdentity = TRUE) */ function containsOnly($type) { - return PHPUnit_Framework_Assert::containsOnly($type); + return call_user_func_array( + 'PHPUnit_Framework_Assert::containsOnly', + func_get_args() + ); +} + +/** + * Returns a PHPUnit_Framework_Constraint_TraversableContainsOnly matcher + * object. + * + * @param string $classname + * @return PHPUnit_Framework_Constraint_TraversableContainsOnly + */ +function containsOnlyInstancesOf($classname) +{ + return call_user_func_array( + 'PHPUnit_Framework_Assert::containsOnlyInstancesOf', + func_get_args() + ); } /** @@ -1575,7 +1928,10 @@ function containsOnly($type) */ function equalTo($value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) { - return PHPUnit_Framework_Assert::equalTo($value, $delta, $maxDepth, $canonicalize, $ignoreCase); + return call_user_func_array( + 'PHPUnit_Framework_Assert::equalTo', + func_get_args() + ); } /** @@ -1588,7 +1944,10 @@ function equalTo($value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ign */ function exactly($count) { - return PHPUnit_Framework_TestCase::exactly($count); + return call_user_func_array( + 'PHPUnit_Framework_TestCase::exactly', + func_get_args() + ); } /** @@ -1599,7 +1958,10 @@ function exactly($count) */ function fileExists() { - return PHPUnit_Framework_Assert::fileExists(); + return call_user_func_array( + 'PHPUnit_Framework_Assert::fileExists', + func_get_args() + ); } /** @@ -1611,7 +1973,10 @@ function fileExists() */ function greaterThan($value) { - return PHPUnit_Framework_Assert::greaterThan($value); + return call_user_func_array( + 'PHPUnit_Framework_Assert::greaterThan', + func_get_args() + ); } /** @@ -1625,7 +1990,10 @@ function greaterThan($value) */ function greaterThanOrEqual($value) { - return PHPUnit_Framework_Assert::greaterThanOrEqual($value); + return call_user_func_array( + 'PHPUnit_Framework_Assert::greaterThanOrEqual', + func_get_args() + ); } /** @@ -1637,7 +2005,10 @@ function greaterThanOrEqual($value) */ function identicalTo($value) { - return PHPUnit_Framework_Assert::identicalTo($value); + return call_user_func_array( + 'PHPUnit_Framework_Assert::identicalTo', + func_get_args() + ); } /** @@ -1648,7 +2019,10 @@ function identicalTo($value) */ function isEmpty() { - return PHPUnit_Framework_Assert::isEmpty(); + return call_user_func_array( + 'PHPUnit_Framework_Assert::isEmpty', + func_get_args() + ); } /** @@ -1659,7 +2033,10 @@ function isEmpty() */ function isFalse() { - return PHPUnit_Framework_Assert::isFalse(); + return call_user_func_array( + 'PHPUnit_Framework_Assert::isFalse', + func_get_args() + ); } /** @@ -1671,7 +2048,24 @@ function isFalse() */ function isInstanceOf($className) { - return PHPUnit_Framework_Assert::isInstanceOf($className); + return call_user_func_array( + 'PHPUnit_Framework_Assert::isInstanceOf', + func_get_args() + ); +} + +/** + * Returns a PHPUnit_Framework_Constraint_IsJson matcher object. + * + * @return PHPUnit_Framework_Constraint_IsJson + * @since Method available since Release 3.7.20 + */ +function isJson() +{ + return call_user_func_array( + 'PHPUnit_Framework_Assert::isJson', + func_get_args() + ); } /** @@ -1682,7 +2076,10 @@ function isInstanceOf($className) */ function isNull() { - return PHPUnit_Framework_Assert::isNull(); + return call_user_func_array( + 'PHPUnit_Framework_Assert::isNull', + func_get_args() + ); } /** @@ -1693,18 +2090,10 @@ function isNull() */ function isTrue() { - return PHPUnit_Framework_Assert::isTrue(); -} - -/** - * Returns a PHPUnit_Framework_Constraint_Callback matcher object. - * - * @param callable $callback - * @return PHPUnit_Framework_Constraint_Callback - */ -function callback($callback) -{ - return PHPUnit_Framework_Assert::callback($callback); + return call_user_func_array( + 'PHPUnit_Framework_Assert::isTrue', + func_get_args() + ); } /** @@ -1716,7 +2105,10 @@ function callback($callback) */ function isType($type) { - return PHPUnit_Framework_Assert::isType($type); + return call_user_func_array( + 'PHPUnit_Framework_Assert::isType', + func_get_args() + ); } /** @@ -1728,7 +2120,10 @@ function isType($type) */ function lessThan($value) { - return PHPUnit_Framework_Assert::lessThan($value); + return call_user_func_array( + 'PHPUnit_Framework_Assert::lessThan', + func_get_args() + ); } /** @@ -1742,7 +2137,10 @@ function lessThan($value) */ function lessThanOrEqual($value) { - return PHPUnit_Framework_Assert::lessThanOrEqual($value); + return call_user_func_array( + 'PHPUnit_Framework_Assert::lessThanOrEqual', + func_get_args() + ); } /** @@ -1753,7 +2151,10 @@ function lessThanOrEqual($value) */ function logicalAnd() { - return PHPUnit_Framework_Assert::logicalAnd(); + return call_user_func_array( + 'PHPUnit_Framework_Assert::logicalAnd', + func_get_args() + ); } /** @@ -1765,7 +2166,10 @@ function logicalAnd() */ function logicalNot(PHPUnit_Framework_Constraint $constraint) { - return PHPUnit_Framework_Assert::logicalNot($constraint); + return call_user_func_array( + 'PHPUnit_Framework_Assert::logicalNot', + func_get_args() + ); } /** @@ -1776,7 +2180,10 @@ function logicalNot(PHPUnit_Framework_Constraint $constraint) */ function logicalOr() { - return PHPUnit_Framework_Assert::logicalOr(); + return call_user_func_array( + 'PHPUnit_Framework_Assert::logicalOr', + func_get_args() + ); } /** @@ -1787,7 +2194,10 @@ function logicalOr() */ function logicalXor() { - return PHPUnit_Framework_Assert::logicalXor(); + return call_user_func_array( + 'PHPUnit_Framework_Assert::logicalXor', + func_get_args() + ); } /** @@ -1799,7 +2209,10 @@ function logicalXor() */ function matches($string) { - return PHPUnit_Framework_Assert::matches($string); + return call_user_func_array( + 'PHPUnit_Framework_Assert::matches', + func_get_args() + ); } /** @@ -1811,7 +2224,10 @@ function matches($string) */ function matchesRegularExpression($pattern) { - return PHPUnit_Framework_Assert::matchesRegularExpression($pattern); + return call_user_func_array( + 'PHPUnit_Framework_Assert::matchesRegularExpression', + func_get_args() + ); } /** @@ -1823,7 +2239,10 @@ function matchesRegularExpression($pattern) */ function never() { - return PHPUnit_Framework_TestCase::never(); + return call_user_func_array( + 'PHPUnit_Framework_TestCase::never', + func_get_args() + ); } /** @@ -1835,7 +2254,10 @@ function never() */ function objectHasAttribute($attributeName) { - return PHPUnit_Framework_Assert::objectHasAttribute($attributeName); + return call_user_func_array( + 'PHPUnit_Framework_Assert::objectHasAttribute', + func_get_args() + ); } /** @@ -1847,7 +2269,10 @@ function objectHasAttribute($attributeName) */ function onConsecutiveCalls() { - return PHPUnit_Framework_TestCase::onConsecutiveCalls(); + return call_user_func_array( + 'PHPUnit_Framework_TestCase::onConsecutiveCalls', + func_get_args() + ); } /** @@ -1859,7 +2284,10 @@ function onConsecutiveCalls() */ function once() { - return PHPUnit_Framework_TestCase::once(); + return call_user_func_array( + 'PHPUnit_Framework_TestCase::once', + func_get_args() + ); } /** @@ -1871,7 +2299,10 @@ function once() */ function returnArgument($argumentIndex) { - return PHPUnit_Framework_TestCase::returnArgument($argumentIndex); + return call_user_func_array( + 'PHPUnit_Framework_TestCase::returnArgument', + func_get_args() + ); } /** @@ -1883,7 +2314,10 @@ function returnArgument($argumentIndex) */ function returnCallback($callback) { - return PHPUnit_Framework_TestCase::returnCallback($callback); + return call_user_func_array( + 'PHPUnit_Framework_TestCase::returnCallback', + func_get_args() + ); } /** @@ -1896,7 +2330,10 @@ function returnCallback($callback) */ function returnSelf() { - return PHPUnit_Framework_TestCase::returnSelf(); + return call_user_func_array( + 'PHPUnit_Framework_TestCase::returnSelf', + func_get_args() + ); } /** @@ -1908,7 +2345,10 @@ function returnSelf() */ function returnValue($value) { - return PHPUnit_Framework_TestCase::returnValue($value); + return call_user_func_array( + 'PHPUnit_Framework_TestCase::returnValue', + func_get_args() + ); } /** @@ -1920,7 +2360,10 @@ function returnValue($value) */ function returnValueMap(array $valueMap) { - return PHPUnit_Framework_TestCase::returnValueMap($valueMap); + return call_user_func_array( + 'PHPUnit_Framework_TestCase::returnValueMap', + func_get_args() + ); } /** @@ -1933,7 +2376,10 @@ function returnValueMap(array $valueMap) */ function stringContains($string, $case = TRUE) { - return PHPUnit_Framework_Assert::stringContains($string, $case); + return call_user_func_array( + 'PHPUnit_Framework_Assert::stringContains', + func_get_args() + ); } /** @@ -1945,7 +2391,10 @@ function stringContains($string, $case = TRUE) */ function stringEndsWith($suffix) { - return PHPUnit_Framework_Assert::stringEndsWith($suffix); + return call_user_func_array( + 'PHPUnit_Framework_Assert::stringEndsWith', + func_get_args() + ); } /** @@ -1957,7 +2406,10 @@ function stringEndsWith($suffix) */ function stringStartsWith($prefix) { - return PHPUnit_Framework_Assert::stringStartsWith($prefix); + return call_user_func_array( + 'PHPUnit_Framework_Assert::stringStartsWith', + func_get_args() + ); } /** @@ -1969,5 +2421,8 @@ function stringStartsWith($prefix) */ function throwException(Exception $exception) { - return PHPUnit_Framework_TestCase::throwException($exception); + return call_user_func_array( + 'PHPUnit_Framework_TestCase::throwException', + func_get_args() + ); } diff --git a/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsJson.php b/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsJson.php new file mode 100644 index 000000000000..c75d0934365e --- /dev/null +++ b/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsJson.php @@ -0,0 +1,109 @@ +<?php +/** + * PHPUnit + * + * Copyright (c) 2001-2013, Sebastian Bergmann <sebastian@phpunit.de>. + * All 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. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may 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. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann <sebastian@phpunit.de> + * @copyright 2001-2013 Sebastian Bergmann <sebastian@phpunit.de> + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://www.phpunit.de/ + * @since File available since Release 3.7.20 + */ + +/** + * Constraint that asserts that a string is valid JSON. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann <sebastian@phpunit.de> + * @copyright 2001-2013 Sebastian Bergmann <sebastian@phpunit.de> + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://www.phpunit.de/ + * @since Class available since Release 3.7.20 + */ +class PHPUnit_Framework_Constraint_IsJson extends PHPUnit_Framework_Constraint +{ + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + json_decode($other); + if (json_last_error()) { + return FALSE; + } + + return TRUE; + } + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + json_decode($other); + $error = PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::determineJsonError( + json_last_error() + ); + + return sprintf( + '%s is valid JSON (%s)', + + PHPUnit_Util_Type::shortenedExport($other), + $error + ); + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'is valid JSON'; + } +} diff --git a/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/JsonMatches.php b/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/JsonMatches.php index 6fff78cbc10f..426af9ec833f 100644 --- a/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/JsonMatches.php +++ b/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/JsonMatches.php @@ -84,33 +84,17 @@ protected function matches($other) { $decodedOther = json_decode($other); if (json_last_error()) { - $this->failure_reason = $this->getJsonError(); return FALSE; } $decodedValue = json_decode($this->value); if (json_last_error()) { - $this->failure_reason = $this->getJsonError(); return FALSE; } return $decodedOther == $decodedValue; } - /** - * Finds the last occurd JSON error. - * - * @param string $messagePrefix - * @return string The last JSON error prefixed with $messagePrefix. - */ - protected function getJsonError($messagePrefix = 'Json error!') - { - return PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::determineJsonError( - json_last_error(), - $messagePrefix - ); - } - /** * Returns a string representation of the object. * diff --git a/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/JsonMatches/ErrorMessageProvider.php b/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/JsonMatches/ErrorMessageProvider.php index 296155a17175..fe6e16a4cb0f 100644 --- a/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/JsonMatches/ErrorMessageProvider.php +++ b/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/JsonMatches/ErrorMessageProvider.php @@ -57,25 +57,25 @@ class PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider { /** - * Translatets accourd JSON error to a human readable string. + * Translates JSON error to a human readable string. * * @param string $error * @return string */ public static function determineJsonError($error, $prefix = '') { - switch (strtoupper($error)) { - case 'JSON_ERROR_NONE': + switch ($error) { + case JSON_ERROR_NONE: return; - case 'JSON_ERROR_DEPTH': + case JSON_ERROR_DEPTH: return $prefix . 'Maximum stack depth exceeded'; - case 'JSON_ERROR_STATE_MISMATCH': + case JSON_ERROR_STATE_MISMATCH: return $prefix . 'Underflow or the modes mismatch'; - case 'JSON_ERROR_CTRL_CHAR': + case JSON_ERROR_CTRL_CHAR: return $prefix . 'Unexpected control character found'; - case 'JSON_ERROR_SYNTAX': + case JSON_ERROR_SYNTAX: return $prefix . 'Syntax error, malformed JSON'; - case 'JSON_ERROR_UTF8': + case JSON_ERROR_UTF8: return $prefix . 'Malformed UTF-8 characters, possibly incorrectly encoded'; default: return $prefix . 'Unknown error'; diff --git a/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/SameSize.php b/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/SameSize.php index ec572f9ad9bd..32ce8bef3b15 100644 --- a/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/SameSize.php +++ b/core/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/SameSize.php @@ -68,6 +68,6 @@ class PHPUnit_Framework_Constraint_SameSize extends PHPUnit_Framework_Constraint */ public function __construct($expected) { - $this->expectedCount = $this->getCountOf($expected); + parent::__construct($this->getCountOf($expected)); } } diff --git a/core/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php b/core/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php index 13a92eeb931c..050134734c26 100644 --- a/core/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php +++ b/core/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php @@ -393,7 +393,7 @@ public function getActualOutput() */ public function hasOutput() { - if (empty($this->output)) { + if (strlen($this->output) === 0) { return FALSE; } diff --git a/core/vendor/phpunit/phpunit/PHPUnit/Framework/TestFailure.php b/core/vendor/phpunit/phpunit/PHPUnit/Framework/TestFailure.php index 683ff4eeb494..6774c7524fd2 100644 --- a/core/vendor/phpunit/phpunit/PHPUnit/Framework/TestFailure.php +++ b/core/vendor/phpunit/phpunit/PHPUnit/Framework/TestFailure.php @@ -88,7 +88,7 @@ public function toString() return sprintf( '%s: %s', - $this->failedTest, + $this->failedTest->toString(), $this->thrownException->getMessage() ); } diff --git a/core/vendor/phpunit/phpunit/PHPUnit/Runner/Version.php b/core/vendor/phpunit/phpunit/PHPUnit/Runner/Version.php index d2b1b682f37e..82061f99fc6e 100644 --- a/core/vendor/phpunit/phpunit/PHPUnit/Runner/Version.php +++ b/core/vendor/phpunit/phpunit/PHPUnit/Runner/Version.php @@ -56,7 +56,7 @@ */ class PHPUnit_Runner_Version { - const VERSION = '3.7.19'; + const VERSION = '3.7.21'; protected static $version; /** diff --git a/core/vendor/phpunit/phpunit/PHPUnit/Util/Configuration.php b/core/vendor/phpunit/phpunit/PHPUnit/Util/Configuration.php index 51a61453adc3..8b52e3abfbf9 100644 --- a/core/vendor/phpunit/phpunit/PHPUnit/Util/Configuration.php +++ b/core/vendor/phpunit/phpunit/PHPUnit/Util/Configuration.php @@ -535,10 +535,23 @@ public function handlePHPConfiguration() } foreach (array('var', 'env', 'post', 'get', 'cookie', 'server', 'files', 'request') as $array) { - if ($array == 'var') { - $target = &$GLOBALS; - } else { - $target = &$GLOBALS['_' . strtoupper($array)]; + // See https://github.com/sebastianbergmann/phpunit/issues/277 + switch ($array) { + case 'var': + $target = &$GLOBALS; + break; + + case 'env': + $target = &$_ENV; + break; + + case 'server': + $target = &$_SERVER; + break; + + default: + $target = &$GLOBALS['_' . strtoupper($array)]; + break; } foreach ($configuration[$array] as $name => $value) { @@ -816,7 +829,7 @@ protected function getTestSuite(DOMElement $testSuiteNode, $testSuiteFilter=null if ($testSuiteFilter && $directoryNode->parentNode->getAttribute('name') != $testSuiteFilter) { continue; } - + $directory = (string)$directoryNode->nodeValue; if (empty($directory)) { @@ -864,7 +877,7 @@ protected function getTestSuite(DOMElement $testSuiteNode, $testSuiteFilter=null if ($testSuiteFilter && $fileNode->parentNode->getAttribute('name') != $testSuiteFilter) { continue; } - + $file = (string)$fileNode->nodeValue; if (empty($file)) { diff --git a/core/vendor/phpunit/phpunit/PHPUnit/Util/ErrorHandler.php b/core/vendor/phpunit/phpunit/PHPUnit/Util/ErrorHandler.php index fb15d69319df..2b419a6e3fbd 100644 --- a/core/vendor/phpunit/phpunit/PHPUnit/Util/ErrorHandler.php +++ b/core/vendor/phpunit/phpunit/PHPUnit/Util/ErrorHandler.php @@ -45,10 +45,10 @@ // Workaround for http://bugs.php.net/bug.php?id=47987, // see https://github.com/sebastianbergmann/phpunit/issues#issue/125 for details -require_once 'PHPUnit/Framework/Error.php'; -require_once 'PHPUnit/Framework/Error/Notice.php'; -require_once 'PHPUnit/Framework/Error/Warning.php'; -require_once 'PHPUnit/Framework/Error/Deprecated.php'; +require_once __DIR__ . '/../Framework/Error.php'; +require_once __DIR__ . '/../Framework/Error/Notice.php'; +require_once __DIR__ . '/../Framework/Error/Warning.php'; +require_once __DIR__ . '/../Framework/Error/Deprecated.php'; /** * Error handler that converts PHP errors and warnings to exceptions. diff --git a/core/vendor/phpunit/phpunit/PHPUnit/Util/Test.php b/core/vendor/phpunit/phpunit/PHPUnit/Util/Test.php index e564ae5180d8..dc28e5ea8c71 100644 --- a/core/vendor/phpunit/phpunit/PHPUnit/Util/Test.php +++ b/core/vendor/phpunit/phpunit/PHPUnit/Util/Test.php @@ -147,6 +147,7 @@ public static function getExpectedException($className, $methodName) { $reflector = new ReflectionMethod($className, $methodName); $docComment = $reflector->getDocComment(); + $docComment = substr($docComment, 3, -2); if (preg_match(self::REGEX_EXPECTED_EXCEPTION, $docComment, $matches)) { $annotations = self::parseTestMethodAnnotations( diff --git a/core/vendor/phpunit/phpunit/Tests/Framework/Assert/FunctionsTest.php b/core/vendor/phpunit/phpunit/Tests/Framework/Assert/FunctionsTest.php new file mode 100644 index 000000000000..2903e49b3238 --- /dev/null +++ b/core/vendor/phpunit/phpunit/Tests/Framework/Assert/FunctionsTest.php @@ -0,0 +1,80 @@ +<?php +/** + * PHPUnit + * + * Copyright (c) 2001-2013, Sebastian Bergmann <sebastian@phpunit.de>. + * All 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. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may 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. + * + * @package PHPUnit + * @author Kuzuha SHINODA <kuzuha01@hotmail.com> + * @copyright 2013-2013 Kuzuha SHINODA <kuzuha01@hotmail.com> + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://www.phpunit.de/ + * @since File available since Release 3.7.20 + */ + +require_once dirname(dirname(dirname(__DIR__))) . '/PHPUnit/Framework/Assert/Functions.php'; + +/** + * + * + * @package PHPUnit + * @author Kuzuha SHINODA <kuzuha01@hotmail.com> + * @copyright 2013-2013 Kuzuha SHINODA <kuzuha01@hotmail.com> + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://www.phpunit.de/ + * @since File available since Release 3.7.20 + */ +class Framework_Assert_FunctionsTest extends PHPUnit_Framework_TestCase +{ + + public function testLogicalAnd() + { + $expected = $this->logicalAnd($this->isTrue(), $this->isFalse()); + $actual = logicalAnd($this->isTrue(), $this->isFalse()); + $this->assertSame($expected->toString(), $actual->toString()); + } + + public function testLogicalOr() + { + $expected = $this->logicalOr($this->isTrue(), $this->isFalse()); + $actual = logicalOr($this->isTrue(), $this->isFalse()); + $this->assertSame($expected->toString(), $actual->toString()); + } + + public function testLogicalXor() + { + $expected = $this->logicalXor($this->isTrue(), $this->isFalse()); + $actual = logicalXor($this->isTrue(), $this->isFalse()); + $this->assertSame($expected->toString(), $actual->toString()); + } +} diff --git a/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php b/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php index c9ad1eb70a4a..a85818edf45d 100644 --- a/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php +++ b/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php @@ -4033,6 +4033,63 @@ public function testAssertCountThrowsExceptionIfElementIsNotCountable() $this->fail(); } + /** + * @covers PHPUnit_Framework_Assert::assertSameSize + */ + public function testAssertSameSize() + { + $this->assertSameSize(array(1,2), array(3,4)); + + try { + $this->assertSameSize(array(1,2), array(1,2,3)); + } + + catch (PHPUnit_Framework_AssertionFailedError $e) { + return; + } + + $this->fail(); + } + + /** + * @covers PHPUnit_Framework_Assert::assertSameSize + */ + public function testAssertSameSizeThrowsExceptionIfExpectedIsNotCoutable() + { + + try { + $this->assertSameSize('a', array()); + } + + catch (PHPUnit_Framework_Exception $e) { + $this->assertEquals('Argument #1 of PHPUnit_Framework_Assert::assertSameSize() must be a countable', $e->getMessage()); + + return; + } + + $this->fail(); + } + + + /** + * @covers PHPUnit_Framework_Assert::assertSameSize + */ + public function testAssertSameSizeThrowsExceptionIfActualIsNotCountable() + { + + try { + $this->assertSameSize(array(), ''); + } + + catch (PHPUnit_Framework_Exception $e) { + $this->assertEquals('Argument #2 of PHPUnit_Framework_Assert::assertSameSize() must be a countable', $e->getMessage()); + + return; + } + + $this->fail(); + } + /** * @covers PHPUnit_Framework_Assert::assertJsonStringEqualsJsonString */ @@ -4053,7 +4110,7 @@ public function testAssertJsonStringEqualsJsonStringErrorRaised($expected, $actu { try { $this->assertJsonStringEqualsJsonString($expected, $actual); - } catch (PHPUnit_Framework_ExpectationFailedException $e) { + } catch (PHPUnit_Framework_AssertionFailedError $e) { return; } $this->fail('Expected exception not found'); @@ -4077,7 +4134,12 @@ public function testAssertJsonStringNotEqualsJsonString() */ public function testAssertJsonStringNotEqualsJsonStringErrorRaised($expected, $actual) { - $this->assertJsonStringNotEqualsJsonString($expected, $actual); + try { + $this->assertJsonStringNotEqualsJsonString($expected, $actual); + } catch (PHPUnit_Framework_AssertionFailedError $e) { + return; + } + $this->fail('Expected exception not found'); } /** diff --git a/core/vendor/phpunit/phpunit/Tests/Framework/Constraint/JsonMatches/ErrorMessageProviderTest.php b/core/vendor/phpunit/phpunit/Tests/Framework/Constraint/JsonMatches/ErrorMessageProviderTest.php index 9755ad9a8e7d..1990ddce28af 100644 --- a/core/vendor/phpunit/phpunit/Tests/Framework/Constraint/JsonMatches/ErrorMessageProviderTest.php +++ b/core/vendor/phpunit/phpunit/Tests/Framework/Constraint/JsonMatches/ErrorMessageProviderTest.php @@ -86,27 +86,27 @@ public static function determineJsonErrorDataprovider() NULL, 'json_error_none', '' ), 'JSON_ERROR_DEPTH' => array( - 'Maximum stack depth exceeded', 'json_error_depth', '' + 'Maximum stack depth exceeded', JSON_ERROR_DEPTH, '' ), 'prefixed JSON_ERROR_DEPTH' => array( - 'TUX: Maximum stack depth exceeded', 'json_error_depth', 'TUX: ' + 'TUX: Maximum stack depth exceeded', JSON_ERROR_DEPTH, 'TUX: ' ), 'JSON_ERROR_STATE_MISMatch' => array( - 'Underflow or the modes mismatch', 'json_error_state_mismatch', '' + 'Underflow or the modes mismatch', JSON_ERROR_STATE_MISMATCH, '' ), 'JSON_ERROR_CTRL_CHAR' => array( - 'Unexpected control character found', 'json_error_ctrl_char', '' + 'Unexpected control character found', JSON_ERROR_CTRL_CHAR, '' ), 'JSON_ERROR_SYNTAX' => array( - 'Syntax error, malformed JSON', 'json_error_syntax', '' + 'Syntax error, malformed JSON', JSON_ERROR_SYNTAX, '' ), 'JSON_ERROR_UTF8`' => array( 'Malformed UTF-8 characters, possibly incorrectly encoded', - 'json_error_utf8', + JSON_ERROR_UTF8, '' ), 'Invalid error indicator' => array( - 'Unknown error', 'invalid_error_indicator', '' + 'Unknown error', 55, '' ), ); } diff --git a/core/vendor/phpunit/phpunit/Tests/Framework/Constraint/JsonMatchesTest.php b/core/vendor/phpunit/phpunit/Tests/Framework/Constraint/JsonMatchesTest.php index 6761710b270f..402675666bd4 100644 --- a/core/vendor/phpunit/phpunit/Tests/Framework/Constraint/JsonMatchesTest.php +++ b/core/vendor/phpunit/phpunit/Tests/Framework/Constraint/JsonMatchesTest.php @@ -58,7 +58,6 @@ class Framework_Constraint_JsonMatchesTest extends PHPUnit_Framework_TestCase * @covers PHPUnit_Framework_Constraint_JsonMatches::evaluate * @covers PHPUnit_Framework_Constraint_JsonMatches::matches * @covers PHPUnit_Framework_Constraint_JsonMatches::__construct - * @covers PHPUnit_Framework_Constraint_JsonMatches::getJsonError */ public function testEvaluate($expected, $jsonOther, $jsonValue) { diff --git a/core/vendor/phpunit/phpunit/Tests/Framework/ConstraintTest.php b/core/vendor/phpunit/phpunit/Tests/Framework/ConstraintTest.php index 9d057b6046ba..3f0375a64586 100644 --- a/core/vendor/phpunit/phpunit/Tests/Framework/ConstraintTest.php +++ b/core/vendor/phpunit/phpunit/Tests/Framework/ConstraintTest.php @@ -3541,6 +3541,99 @@ public function testConstraintNotCountFailing() <<<EOF Failed asserting that actual size 2 does not match expected size 2. +EOF + , + PHPUnit_Framework_TestFailure::exceptionToString($e) + ); + + return; + } + + $this->fail(); + } + + /** + * @covers PHPUnit_Framework_Constraint_SameSize + */ + public function testConstraintSameSizeWithAnArray() + { + $constraint = new PHPUnit_Framework_Constraint_SameSize(array(1,2,3,4,5)); + + $this->assertTrue($constraint->evaluate(array(6,7,8,9,10), '', TRUE)); + $this->assertFalse($constraint->evaluate(array(1,2,3,4), '', TRUE)); + } + + /** + * @covers PHPUnit_Framework_Constraint_SameSize + */ + public function testConstraintSameSizeWithAnIteratorWhichDoesNotImplementCountable() + { + $constraint = new PHPUnit_Framework_Constraint_SameSize(new TestIterator(array(1,2,3,4,5))); + + $this->assertTrue($constraint->evaluate(new TestIterator(array(6,7,8,9,10)), '', TRUE)); + $this->assertFalse($constraint->evaluate(new TestIterator(array(1,2,3,4)), '', TRUE)); + } + + /** + * @covers PHPUnit_Framework_Constraint_SameSize + */ + public function testConstraintSameSizeWithAnObjectImplementingCountable() + { + $constraint = new PHPUnit_Framework_Constraint_SameSize(new ArrayObject(array(1,2,3,4,5))); + + $this->assertTrue($constraint->evaluate(new ArrayObject(array(6,7,8,9,10)), '', TRUE)); + $this->assertFalse($constraint->evaluate(new ArrayObject(array(1,2,3,4)), '', TRUE)); + } + + /** + * @covers PHPUnit_Framework_Constraint_SameSize + * @covers PHPUnit_Framework_TestFailure::exceptionToString + */ + public function testConstraintSameSizeFailing() + { + $constraint = new PHPUnit_Framework_Constraint_SameSize(array(1,2,3,4,5)); + + try { + $constraint->evaluate(array(1,2)); + } + + catch (PHPUnit_Framework_ExpectationFailedException $e) { + $this->assertEquals( + <<<EOF +Failed asserting that actual size 2 matches expected size 5. + +EOF + , + PHPUnit_Framework_TestFailure::exceptionToString($e) + ); + + return; + } + + $this->fail(); + } + + /** + * @covers PHPUnit_Framework_Constraint_SameSize + * @covers PHPUnit_Framework_Constraint_Not + * @covers PHPUnit_Framework_Assert::logicalNot + * @covers PHPUnit_Framework_TestFailure::exceptionToString + */ + public function testConstraintNotSameSizeFailing() + { + $constraint = PHPUnit_Framework_Assert::logicalNot( + new PHPUnit_Framework_Constraint_SameSize(array(1,2)) + ); + + try { + $constraint->evaluate(array(3,4)); + } + + catch (PHPUnit_Framework_ExpectationFailedException $e) { + $this->assertEquals( + <<<EOF +Failed asserting that actual size 2 does not match expected size 2. + EOF , PHPUnit_Framework_TestFailure::exceptionToString($e) diff --git a/core/vendor/phpunit/phpunit/Tests/Framework/TestFailureTest.php b/core/vendor/phpunit/phpunit/Tests/Framework/TestFailureTest.php new file mode 100644 index 000000000000..1257100dff65 --- /dev/null +++ b/core/vendor/phpunit/phpunit/Tests/Framework/TestFailureTest.php @@ -0,0 +1,68 @@ +<?php +/** + * PHPUnit + * + * Copyright (c) 2001-2013, Sebastian Bergmann <sebastian@phpunit.de>. + * All 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. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may 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. + * + * @package PHPUnit + * @author Sebastian Bergmann <sebastian@phpunit.de> + * @copyright 2001-2013 Sebastian Bergmann <sebastian@phpunit.de> + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://www.phpunit.de/ + * @since File available since Release 3.7.20 + */ + +/** + * + * + * @package PHPUnit + * @author Sebastian Bergmann <sebastian@phpunit.de> + * @copyright 2001-2013 Sebastian Bergmann <sebastian@phpunit.de> + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://www.phpunit.de/ + * @since File available since Release 3.7.20 + */ +class Framework_TestFailureTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers PHPUnit_Framework_TestFailure::toString + */ + public function testToString() + { + $test = new self(__FUNCTION__); + $exception = new PHPUnit_Framework_Exception('message'); + $failure = new PHPUnit_Framework_TestFailure($test, $exception); + + $this->assertEquals(__METHOD__ . ': message', $failure->toString()); + } +} \ No newline at end of file diff --git a/core/vendor/phpunit/phpunit/Tests/Util/TestTest.php b/core/vendor/phpunit/phpunit/Tests/Util/TestTest.php index 3e4bf03f6b58..f57e4e722679 100644 --- a/core/vendor/phpunit/phpunit/Tests/Util/TestTest.php +++ b/core/vendor/phpunit/phpunit/Tests/Util/TestTest.php @@ -104,6 +104,10 @@ public function testGetExpectedException() array('class' => 'Class', 'code' => ExceptionTest::ERROR_CODE, 'message' => ExceptionTest::ERROR_MESSAGE), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testNine') ); + $this->assertSame( + array('class' => 'Class', 'code' => NULL, 'message' => ''), + PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testSingleLine') + ); $this->assertSame( array('class' => 'Class', 'code' => My\Space\ExceptionNamespaceTest::ERROR_CODE, 'message' => My\Space\ExceptionNamespaceTest::ERROR_MESSAGE), PHPUnit_Util_Test::getExpectedException('My\Space\ExceptionNamespaceTest', 'testConstants') diff --git a/core/vendor/phpunit/phpunit/Tests/_files/ExceptionTest.php b/core/vendor/phpunit/phpunit/Tests/_files/ExceptionTest.php index 3493743e4274..529846515354 100644 --- a/core/vendor/phpunit/phpunit/Tests/_files/ExceptionTest.php +++ b/core/vendor/phpunit/phpunit/Tests/_files/ExceptionTest.php @@ -86,6 +86,11 @@ public function testNine() { } + /** @expectedException Class */ + public function testSingleLine() + { + } + /** * @expectedException Class * @expectedExceptionCode ExceptionTest::UNKNOWN_CODE_CONSTANT diff --git a/core/vendor/phpunit/phpunit/build/assertions.php b/core/vendor/phpunit/phpunit/build/assertions.php index acaa822326a8..fa965f5b0932 100755 --- a/core/vendor/phpunit/phpunit/build/assertions.php +++ b/core/vendor/phpunit/phpunit/build/assertions.php @@ -50,7 +50,7 @@ foreach ($methods as $name => $data) { $buffer .= sprintf( - "\n\n%s\nfunction %s(%s)\n{\n return %s::%s(%s);\n}", + "\n\n%s\nfunction %s(%s)\n{\n return call_user_func_array(\n '%s::%s',\n func_get_args()\n );\n}", str_replace(' ', '', $data['docblock']), $name, $data['sigDecl'], diff --git a/core/vendor/phpunit/phpunit/composer.json b/core/vendor/phpunit/phpunit/composer.json index fb57665ef344..0993e3b4b5cc 100644 --- a/core/vendor/phpunit/phpunit/composer.json +++ b/core/vendor/phpunit/phpunit/composer.json @@ -27,7 +27,7 @@ "phpunit/php-code-coverage": ">=1.2.1,<1.3.0", "phpunit/php-timer": ">=1.0.2,<1.1.0", "phpunit/phpunit-mock-objects": ">=1.2.0,<1.3.0", - "symfony/yaml": ">=2.0.0,<2.3.0", + "symfony/yaml": "~2.0", "ext-dom": "*", "ext-pcre": "*", "ext-reflection": "*", diff --git a/core/vendor/phpunit/phpunit/package.xml b/core/vendor/phpunit/phpunit/package.xml index 8eca51a6cf9b..ddc89d3a2f48 100644 --- a/core/vendor/phpunit/phpunit/package.xml +++ b/core/vendor/phpunit/phpunit/package.xml @@ -17,9 +17,9 @@ <email>sebastian@phpunit.de</email> <active>yes</active> </lead> - <date>2013-03-25</date> + <date>2013-05-23</date> <version> - <release>3.7.19</release> + <release>3.7.21</release> <api>3.7.0</api> </version> <stability> @@ -82,6 +82,7 @@ <file baseinstalldir="/" name="IsFalse.php" role="php" /> <file baseinstalldir="/" name="IsIdentical.php" role="php" /> <file baseinstalldir="/" name="IsInstanceOf.php" role="php" /> + <file baseinstalldir="/" name="IsJson.php" role="php" /> <file baseinstalldir="/" name="IsNull.php" role="php" /> <file baseinstalldir="/" name="IsTrue.php" role="php" /> <file baseinstalldir="/" name="IsType.php" role="php" /> @@ -246,7 +247,7 @@ <name>Yaml</name> <channel>pear.symfony.com</channel> <min>2.0.0</min> - <max>2.2.99</max> + <max>2.99.99</max> </package> <extension> <name>dom</name> diff --git a/core/vendor/phpunit/phpunit/phpdox.xml.dist b/core/vendor/phpunit/phpunit/phpdox.xml.dist index 04af02aa1aa3..b6312210bae6 100644 --- a/core/vendor/phpunit/phpunit/phpdox.xml.dist +++ b/core/vendor/phpunit/phpunit/phpdox.xml.dist @@ -8,7 +8,9 @@ </collector> <generator output="build"> - <build engine="html" enabled="true" output="api"/> + <build engine="html" enabled="true" output="api"> + <file extension="html" /> + </build> </generator> </project> </phpdox> diff --git a/core/vendor/phpunit/phpunit/phpunit.xml.dist b/core/vendor/phpunit/phpunit/phpunit.xml.dist index a45f5d65b2a0..ee1d8f5cf85a 100644 --- a/core/vendor/phpunit/phpunit/phpunit.xml.dist +++ b/core/vendor/phpunit/phpunit/phpunit.xml.dist @@ -1,8 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated by PHP Project Wizard (PPW) 1.1.0-dev on Sat Mar 12 12:47:10 CET 2011 --> - <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="http://phpunit.de/phpunit.xsd" + xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/3.7/phpunit.xsd" bootstrap="PHPUnit/Autoload.php" backupGlobals="false" verbose="true"> diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainRouter.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainRouter.php index 23a43d47b4aa..2ed85e0ddad4 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainRouter.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainRouter.php @@ -165,6 +165,9 @@ private function doMatch($url, Request $request = null) // the request/url match logic is the same as in Symfony/Component/HttpKernel/EventListener/RouterListener.php // matching requests is more powerful than matching URLs only, so try that first if ($router instanceof RequestMatcherInterface) { + if (null === $request) { + $request = Request::create($url); + } return $router->matchRequest($request); } // every router implements the match method diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteObjectInterface.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteObjectInterface.php index 69e1e3369f8f..16b760a2562b 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteObjectInterface.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteObjectInterface.php @@ -33,7 +33,7 @@ interface RouteObjectInterface /** * Field name for an explicit template to be used with this route. - * i.e. SymfonyCmfContentBundle:StaticContent:index.html.twig + * i.e. CmfContentBundle:StaticContent:index.html.twig */ const TEMPLATE_NAME = '_template'; diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldByClassEnhancerTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldByClassEnhancerTest.php index d7eb0a86529d..85fc2d381444 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldByClassEnhancerTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldByClassEnhancerTest.php @@ -21,7 +21,7 @@ public function setUp() $this->document = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Enhancer\\RouteObject'); $mapping = array('Symfony\\Cmf\\Component\\Routing\\Tests\\Enhancer\\RouteObject' - => 'symfony_cmf_content.controller:indexAction'); + => 'cmf_content.controller:indexAction'); $this->mapper = new FieldByClassEnhancer('_content', '_controller', $mapping); @@ -34,7 +34,7 @@ public function testClassFoundInMapping() $defaults = array('_content' => $this->document); $expected = array( '_content' => $this->document, - '_controller' => 'symfony_cmf_content.controller:indexAction', + '_controller' => 'cmf_content.controller:indexAction', ); $this->assertEquals($expected, $this->mapper->enhance($defaults, $this->request)); } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldMapEnhancerTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldMapEnhancerTest.php index fa76a0348ce6..9e7ca861b56d 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldMapEnhancerTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldMapEnhancerTest.php @@ -22,7 +22,7 @@ class FieldMapEnhancerTest extends CmfUnitTestCase public function setUp() { $this->request = Request::create('/test'); - $mapping = array('static_pages' => 'symfony_cmf_content.controller:indexAction'); + $mapping = array('static_pages' => 'cmf_content.controller:indexAction'); $this->enhancer = new FieldMapEnhancer('type', '_controller', $mapping); } @@ -32,7 +32,7 @@ public function testFieldFoundInMapping() $defaults = array('type' => 'static_pages'); $expected = array( 'type' => 'static_pages', - '_controller' => 'symfony_cmf_content.controller:indexAction', + '_controller' => 'cmf_content.controller:indexAction', ); $this->assertEquals($expected, $this->enhancer->enhance($defaults, $this->request)); } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldPresenceEnhancerTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldPresenceEnhancerTest.php index f2a4aebbd5e5..e389be2d377c 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldPresenceEnhancerTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldPresenceEnhancerTest.php @@ -18,7 +18,7 @@ class FieldPresenceEnhancerTest extends CmfUnitTestCase public function setUp() { - $this->mapper = new FieldPresenceEnhancer('_template', '_controller', 'symfony_cmf_content.controller:indexAction'); + $this->mapper = new FieldPresenceEnhancer('_template', '_controller', 'cmf_content.controller:indexAction'); $this->request = Request::create('/test'); } @@ -28,7 +28,7 @@ public function testHasTemplate() $defaults = array('_template' => 'Bundle:Topic:template.html.twig'); $expected = array( '_template' => 'Bundle:Topic:template.html.twig', - '_controller' => 'symfony_cmf_content.controller:indexAction', + '_controller' => 'cmf_content.controller:indexAction', ); $this->assertEquals($expected, $this->mapper->enhance($defaults, $this->request)); } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/NestedMatcher/UrlMatcherTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/NestedMatcher/UrlMatcherTest.php index 66e99d106df9..7360a72464e8 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/NestedMatcher/UrlMatcherTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/NestedMatcher/UrlMatcherTest.php @@ -24,11 +24,6 @@ class UrlMatcherTest extends CmfUnitTestCase public function setUp() { - $reflection = new \ReflectionClass('Symfony\\Component\\Routing\\Matcher\\UrlMatcher'); - if (! $reflection->hasMethod('getAttributes')) { - $this->markTestSkipped('This only works with symfony 2.2'); - } - $this->routeDocument = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults', 'getRouteKey', 'compile')); $this->routeCompiled = $this->buildMock('Symfony\\Component\\Routing\\CompiledRoute'); diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ChainRouterTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ChainRouterTest.php index adaafd6e003c..893397d4632a 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ChainRouterTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ChainRouterTest.php @@ -235,6 +235,39 @@ public function testMatchRequest() $this->assertEquals(array('test'), $result); } + /** + * Call match on ChainRouter that has RequestMatcher in the chain. + */ + public function testMatchWithRequestMatchers() + { + $url = '/test'; + $request = Request::create('/test'); + + list($low) = $this->createRouterMocks(); + + $high = $this->getMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RequestMatcher'); + + $high + ->expects($this->once()) + ->method('matchRequest') + ->with($request) + ->will($this->throwException(new \Symfony\Component\Routing\Exception\ResourceNotFoundException)) + ; + $low + ->expects($this->once()) + ->method('match') + ->with($url) + ->will($this->returnValue(array('test'))) + ; + + $this->router->add($low, 10); + $this->router->add($high, 20); + + $result = $this->router->match($url); + $this->assertEquals(array('test'), $result); + } + + /** * If there is a method not allowed but another router matches, that one is used */ diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ContentAwareGeneratorTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ContentAwareGeneratorTest.php index 197266cc6789..16d3605712ab 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ContentAwareGeneratorTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ContentAwareGeneratorTest.php @@ -120,7 +120,7 @@ public function testGenerateRouteMultilang() $this->assertEquals('result_url', $this->generator->generate($route_en, array('_locale' => 'de'))); } - public function testGenerateRouteMultilangNomatch() + public function testGenerateRouteMultilangLocaleNomatch() { $route_en = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults', 'compile', 'getRouteContent')); $route_en->setLocale('en'); @@ -228,6 +228,28 @@ public function testGenerateDocumentMultilang() $this->assertEquals('result_url', $this->generator->generate($this->contentDocument, array('_locale' => 'de'))); } + public function testGenerateDocumentMultilangLocaleNomatch() + { + $route_en = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults', 'compile')); + $route_en->setLocale('en'); + $route_de = $this->routeDocument; + $route_de->setLocale('de'); + + $this->contentDocument->expects($this->once()) + ->method('getRoutes') + ->will($this->returnValue(array($route_en, $route_de))) + ; + $route_en->expects($this->once()) + ->method('compile') + ->will($this->returnValue($this->routeCompiled)) + ; + $route_de->expects($this->never()) + ->method('compile') + ; + + $this->assertEquals('result_url', $this->generator->generate($this->contentDocument, array('_locale' => 'fr'))); + } + /** * @expectedException Symfony\Component\Routing\Exception\RouteNotFoundException */ diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/composer.json b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/composer.json index 7d077e54bb60..8559c1aa7616 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/composer.json +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/composer.json @@ -14,8 +14,8 @@ "minimum-stability": "dev", "require": { "php": ">=5.3.2", - "symfony/routing": ">=2.2,<2.3-dev", - "symfony/http-kernel": ">=2.2,<2.3-dev", + "symfony/routing": ">=2.2,<2.4-dev", + "symfony/http-kernel": ">=2.2,<2.4-dev", "psr/log": "~1.0" }, "suggest": { diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/CHANGELOG.md b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/CHANGELOG.md index 694e7139e6ef..54ffb642e69d 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/CHANGELOG.md +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +2.3.0 +----- + + * added a WinCacheClassLoader for WinCache + 2.1.0 ----- diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php index 6a0ea6b8f851..be1c7e2b5563 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -63,7 +63,7 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = // auto-reload $reload = false; if ($autoReload) { - $metadata = $cacheDir.'/'.$name.$extension.'.meta'; + $metadata = $cache.'.meta'; if (!is_file($metadata) || !is_file($cache)) { $reload = true; } else { diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassLoader.php index a2038a0d9f8c..1a359794ab2c 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassLoader.php @@ -164,13 +164,9 @@ public function loadClass($class) */ public function findFile($class) { - if ('\\' == $class[0]) { - $class = substr($class, 1); - } - if (false !== $pos = strrpos($class, '\\')) { // namespaced class name - $classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR; + $classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)).DIRECTORY_SEPARATOR; $className = substr($class, $pos + 1); } else { // PEAR-like class name @@ -178,21 +174,21 @@ public function findFile($class) $className = $class; } - $classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; + $classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; foreach ($this->prefixes as $prefix => $dirs) { if (0 === strpos($class, $prefix)) { foreach ($dirs as $dir) { - if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) { - return $dir . DIRECTORY_SEPARATOR . $classPath; + if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) { + return $dir.DIRECTORY_SEPARATOR.$classPath; } } } } foreach ($this->fallbackDirs as $dir) { - if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) { - return $dir . DIRECTORY_SEPARATOR . $classPath; + if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) { + return $dir.DIRECTORY_SEPARATOR.$classPath; } } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassMapGenerator.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassMapGenerator.php index b0e6580df66a..3b09305954f3 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -121,7 +121,7 @@ private static function findClasses($path) } } - $classes[] = ltrim($namespace . $class, '\\'); + $classes[] = ltrim($namespace.$class, '\\'); break; default: break; diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/MapClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/MapClassLoader.php index cf17d42642cb..82010a77aebb 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/MapClassLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/MapClassLoader.php @@ -47,10 +47,6 @@ public function register($prepend = false) */ public function loadClass($class) { - if ('\\' === $class[0]) { - $class = substr($class, 1); - } - if (isset($this->map[$class])) { require $this->map[$class]; } @@ -65,10 +61,6 @@ public function loadClass($class) */ public function findFile($class) { - if ('\\' === $class[0]) { - $class = substr($class, 1); - } - if (isset($this->map[$class])) { return $this->map[$class]; } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassLoaderTest.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassLoaderTest.php index cf501980a045..9dae537442f5 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassLoaderTest.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassLoaderTest.php @@ -54,8 +54,6 @@ public function getLoadClassTests() return array( array('\\Namespaced2\\Foo', 'Namespaced2\\Foo', '->loadClass() loads Namespaced2\Foo class'), array('\\Pearlike2_Foo', 'Pearlike2_Foo', '->loadClass() loads Pearlike2_Foo class'), - array('\\Namespaced2\\Bar', '\\Namespaced2\\Bar', '->loadClass() loads Namespaced2\Bar class with a leading slash'), - array('\\Pearlike2_Bar', '\\Pearlike2_Bar', '->loadClass() loads Pearlike2_Bar class with a leading slash'), ); } @@ -100,7 +98,7 @@ public function testUseIncludePath() $loader->setUseIncludePath(true); $this->assertTrue($loader->getUseIncludePath()); - set_include_path(__DIR__.'/Fixtures/includepath' . PATH_SEPARATOR . $includePath); + set_include_path(__DIR__.'/Fixtures/includepath'.PATH_SEPARATOR.$includePath); $this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'includepath'.DIRECTORY_SEPARATOR.'Foo.php', $loader->findFile('Foo')); diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php index c4ef810ca174..18f64f75887e 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php @@ -125,7 +125,7 @@ public function testCreateMapFinderSupport() } $finder = new \Symfony\Component\Finder\Finder(); - $finder->files()->in(__DIR__ . '/Fixtures/beta/NamespaceCollision'); + $finder->files()->in(__DIR__.'/Fixtures/beta/NamespaceCollision'); $this->assertEqualsNormalized(array( 'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php', diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/DebugClassLoaderTest.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/DebugClassLoaderTest.php index ffbcafbd2267..873515c3369f 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/DebugClassLoaderTest.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/DebugClassLoaderTest.php @@ -42,6 +42,7 @@ public function testIdempotence() $reflProp->setAccessible(true); $this->assertNotInstanceOf('Symfony\Component\ClassLoader\DebugClassLoader', $reflProp->getValue($function[0])); + return; } } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/UniversalClassLoaderTest.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/UniversalClassLoaderTest.php index 308700b18b2e..6bd7e4362177 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/UniversalClassLoaderTest.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/UniversalClassLoaderTest.php @@ -32,8 +32,6 @@ public function getLoadClassTests() return array( array('\\Namespaced\\Foo', 'Namespaced\\Foo', '->loadClass() loads Namespaced\Foo class'), array('\\Pearlike_Foo', 'Pearlike_Foo', '->loadClass() loads Pearlike_Foo class'), - array('\\Namespaced\\Bar', '\\Namespaced\\Bar', '->loadClass() loads Namespaced\Bar class with a leading slash'), - array('\\Pearlike_Bar', '\\Pearlike_Bar', '->loadClass() loads Pearlike_Bar class with a leading slash'), ); } @@ -49,7 +47,7 @@ public function testUseIncludePath() $loader->useIncludePath(true); $this->assertTrue($loader->getUseIncludePath()); - set_include_path(__DIR__.'/Fixtures/includepath' . PATH_SEPARATOR . $includePath); + set_include_path(__DIR__.'/Fixtures/includepath'.PATH_SEPARATOR.$includePath); $this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'includepath'.DIRECTORY_SEPARATOR.'Foo.php', $loader->findFile('Foo')); diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php index ee16e4809c89..734af7430c59 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php @@ -263,10 +263,6 @@ public function loadClass($class) */ public function findFile($class) { - if ('\\' == $class[0]) { - $class = substr($class, 1); - } - if (false !== $pos = strrpos($class, '\\')) { // namespaced class name $namespace = substr($class, 0, $pos); diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/WinCacheClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/WinCacheClassLoader.php new file mode 100644 index 000000000000..3d09fa99f905 --- /dev/null +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/WinCacheClassLoader.php @@ -0,0 +1,133 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\ClassLoader; + +/** + * WinCacheClassLoader implements a wrapping autoloader cached in WinCache. + * + * It expects an object implementing a findFile method to find the file. This + * allow using it as a wrapper around the other loaders of the component (the + * ClassLoader and the UniversalClassLoader for instance) but also around any + * other autoloader following this convention (the Composer one for instance) + * + * $loader = new ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * $cachedLoader = new WinCacheClassLoader('my_prefix', $loader); + * + * // activate the cached autoloader + * $cachedLoader->register(); + * + * // eventually deactivate the non-cached loader if it was registered previously + * // to be sure to use the cached one. + * $loader->unregister(); + * + * @author Fabien Potencier <fabien@symfony.com> + * @author Kris Wallsmith <kris@symfony.com> + * @author Artem Ryzhkov <artem@smart-core.org> + */ +class WinCacheClassLoader +{ + private $prefix; + + /** + * The class loader object being decorated. + * + * @var \Symfony\Component\ClassLoader\ClassLoader + * A class loader object that implements the findFile() method. + */ + protected $decorated; + + /** + * Constructor. + * + * @param string $prefix The WinCache namespace prefix to use. + * @param object $decorated A class loader object that implements the findFile() method. + * + * @throws \RuntimeException + * @throws \InvalidArgumentException + */ + public function __construct($prefix, $decorated) + { + if (!extension_loaded('wincache')) { + throw new \RuntimeException('Unable to use WinCacheClassLoader as WinCache is not enabled.'); + } + + if (!method_exists($decorated, 'findFile')) { + throw new \InvalidArgumentException('The class finder must implement a "findFile" method.'); + } + + $this->prefix = $prefix; + $this->decorated = $decorated; + } + + /** + * Registers this instance as an autoloader. + * + * @param Boolean $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 Boolean|null True, if loaded + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + require $file; + + return true; + } + } + + /** + * Finds a file by class name while caching lookups to WinCache. + * + * @param string $class A class name to resolve to file + * + * @return string|null + */ + public function findFile($class) + { + if (false === $file = wincache_ucache_get($this->prefix.$class)) { + wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class), 0); + } + + return $file; + } + + /** + * Passes through all unknown calls onto the decorated object. + */ + public function __call($method, $args) + { + return call_user_func_array(array($this->decorated, $method), $args); + } +} diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/composer.json b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/composer.json index 57f2f3408b10..06a1c624b24b 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/composer.json +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/composer.json @@ -28,7 +28,7 @@ "target-dir": "Symfony/Component/ClassLoader", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/.gitignore b/core/vendor/symfony/debug/Symfony/Component/Debug/.gitignore new file mode 100644 index 000000000000..c49a5d8df5c6 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +phpunit.xml diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md b/core/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md new file mode 100644 index 000000000000..2ad5ce695c36 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md @@ -0,0 +1,7 @@ +CHANGELOG +========= + +2.3.0 +----- + + * added the component diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Debug.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Debug.php new file mode 100644 index 000000000000..2e36805ca3c6 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Debug.php @@ -0,0 +1,58 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug; + +use Symfony\Component\ClassLoader\DebugClassLoader; + +/** + * Registers all the debug tools. + * + * @author Fabien Potencier <fabien@symfony.com> + */ +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 integer $errorReportingLevel The level of error reporting you want + * @param Boolean $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; + + error_reporting(-1); + + ErrorHandler::register($errorReportingLevel, $displayErrors); + if ('cli' !== php_sapi_name()) { + ExceptionHandler::register(); + // CLI - display errors only if they're not already logged to STDERR + } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) { + ini_set('display_errors', 1); + } + + if (class_exists('Symfony\Component\ClassLoader\DebugClassLoader')) { + DebugClassLoader::enable(); + } + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php b/core/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php new file mode 100644 index 000000000000..07ee7c1b6c97 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php @@ -0,0 +1,165 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug; + +use Symfony\Component\Debug\Exception\FatalErrorException; +use Symfony\Component\Debug\Exception\ContextErrorException; +use Psr\Log\LoggerInterface; + +/** + * ErrorHandler. + * + * @author Fabien Potencier <fabien@symfony.com> + * @author Konstantin Myakshin <koc-dp@yandex.ru> + */ +class ErrorHandler +{ + const TYPE_DEPRECATION = -100; + + private $levels = array( + E_WARNING => 'Warning', + E_NOTICE => 'Notice', + E_USER_ERROR => 'User Error', + E_USER_WARNING => 'User Warning', + E_USER_NOTICE => 'User Notice', + E_STRICT => 'Runtime Notice', + E_RECOVERABLE_ERROR => 'Catchable Fatal Error', + E_DEPRECATED => 'Deprecated', + E_USER_DEPRECATED => 'User Deprecated', + E_ERROR => 'Error', + E_CORE_ERROR => 'Core Error', + E_COMPILE_ERROR => 'Compile Error', + E_PARSE => 'Parse', + ); + + private $level; + + private $reservedMemory; + + private $displayErrors; + + /** + * @var LoggerInterface[] Loggers for channels + */ + private static $loggers = array(); + + /** + * Registers the error handler. + * + * @param integer $level The level at which the conversion to Exception is done (null to use the error_reporting() value and 0 to disable) + * @param Boolean $displayErrors Display errors (for dev environment) or just log they (production usage) + * + * @return The registered error handler + */ + public static function register($level = null, $displayErrors = true) + { + $handler = new static(); + $handler->setLevel($level); + $handler->setDisplayErrors($displayErrors); + + ini_set('display_errors', 0); + set_error_handler(array($handler, 'handle')); + register_shutdown_function(array($handler, 'handleFatal')); + $handler->reservedMemory = str_repeat('x', 10240); + + return $handler; + } + + public function setLevel($level) + { + $this->level = null === $level ? error_reporting() : $level; + } + + public function setDisplayErrors($displayErrors) + { + $this->displayErrors = $displayErrors; + } + + public static function setLogger(LoggerInterface $logger, $channel = 'deprecation') + { + self::$loggers[$channel] = $logger; + } + + /** + * @throws ContextErrorException When error_reporting returns error + */ + public function handle($level, $message, $file = 'unknown', $line = 0, $context = array()) + { + if (0 === $this->level) { + return false; + } + + if ($level & (E_USER_DEPRECATED | E_DEPRECATED)) { + if (isset(self::$loggers['deprecation'])) { + if (version_compare(PHP_VERSION, '5.4', '<')) { + $stack = array_map( + function ($row) { + unset($row['args']); + return $row; + }, + array_slice(debug_backtrace(false), 0, 10) + ); + } else { + $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10); + } + + self::$loggers['deprecation']->warning($message, array('type' => self::TYPE_DEPRECATION, 'stack' => $stack)); + } + + return true; + } + + if ($this->displayErrors && error_reporting() & $level && $this->level & $level) { + throw new ContextErrorException(sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line), 0, $level, $file, $line, $context); + } + + return false; + } + + public function handleFatal() + { + if (null === $error = error_get_last()) { + return; + } + + unset($this->reservedMemory); + $type = $error['type']; + if (0 === $this->level || !in_array($type, array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE))) { + return; + } + + if (isset(self::$loggers['emergency'])) { + $fatal = array( + 'type' => $type, + 'file' => $error['file'], + 'line' => $error['line'], + ); + + self::$loggers['emergency']->emerg($error['message'], $fatal); + } + + if (!$this->displayErrors) { + return; + } + + // get current exception handler + $exceptionHandler = set_exception_handler(function() {}); + restore_exception_handler(); + + if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandler) { + $level = isset($this->levels[$type]) ? $this->levels[$type] : $type; + $message = sprintf('%s: %s in %s line %d', $level, $error['message'], $error['file'], $error['line']); + $exception = new FatalErrorException($message, 0, $type, $error['file'], $error['line']); + $exceptionHandler[0]->handle($exception); + } + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php new file mode 100644 index 000000000000..2e0115f0cfec --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php @@ -0,0 +1,36 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Exception; + +/** + * Error Exception with Variable Context. + * + * @author Christian Sciberras <uuf6429@gmail.com> + */ +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 occured + */ + public function getContext() + { + return $this->context; + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php new file mode 100644 index 000000000000..bf37ef809857 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php @@ -0,0 +1,21 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Exception; + +/** + * Fatal Error Exception. + * + * @author Konstanton Myakshin <koc-dp@yandex.ru> + */ +class FatalErrorException extends \ErrorException +{ +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php new file mode 100644 index 000000000000..4f0e815f9706 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php @@ -0,0 +1,277 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Exception; + +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 <fabien@symfony.com> + */ +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()); + } + + 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) + { + $trace = $exception->getTrace(); + + if ($exception instanceof FatalErrorException) { + if (function_exists('xdebug_get_function_stack')) { + $trace = array_slice(array_reverse(xdebug_get_function_stack()), 4); + + foreach ($trace as $i => $frame) { + // XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695 + if (!isset($frame['type'])) { + $trace[$i]['type'] = '??'; + } + + if ('dynamic' === $trace[$i]['type']) { + $trace[$i]['type'] = '->'; + } elseif ('static' === $trace[$i]['type']) { + $trace[$i]['type'] = '::'; + } + + // XDebug also has a different name for the parameters array + if (isset($frame['params']) && !isset($frame['args'])) { + $trace[$i]['args'] = $frame['params']; + unset($trace[$i]['params']); + } + } + } else { + $trace = array_slice(array_reverse($trace), 1); + } + } + + $this->setTrace($trace, $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) + { + $result = array(); + foreach ($args as $key => $value) { + 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)); + } + } 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/core/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php b/core/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php new file mode 100644 index 000000000000..cd781b560977 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php @@ -0,0 +1,316 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug; + +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Debug\Exception\FlattenException; + +if (!defined('ENT_SUBSTITUTE')) { + define('ENT_SUBSTITUTE', 8); +} + +/** + * 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 <fabien@symfony.com> + */ +class ExceptionHandler +{ + private $debug; + private $charset; + + public function __construct($debug = true, $charset = 'UTF-8') + { + $this->debug = $debug; + $this->charset = $charset; + } + + /** + * Registers the exception handler. + * + * @param Boolean $debug + * + * @return ExceptionHandler The registered exception handler + */ + public static function register($debug = true) + { + $handler = new static($debug); + + set_exception_handler(array($handler, 'handle')); + + return $handler; + } + + /** + * 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 + */ + public function handle(\Exception $exception) + { + if (class_exists('Symfony\Component\HttpFoundation\Response')) { + $this->createResponse($exception)->send(); + } 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); + } + + header(sprintf('HTTP/1.0 %s', $exception->getStatusCode())); + foreach ($exception->getHeaders() as $name => $value) { + header($name.': '.$value, false); + } + + 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 new Response($this->decorate($this->getContent($exception), $this->getStylesheet($exception)), $exception->getStatusCode(), $exception->getHeaders()); + } + + /** + * 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->abbrClass($e['class']); + $message = nl2br($e['message']); + $content .= sprintf(<<<EOF + <div class="block_exception clear_fix"> + <h2><span>%d/%d</span> %s: %s</h2> + </div> + <div class="block"> + <ol class="traces list_exception"> + +EOF + , $ind, $total, $class, $message); + foreach ($e['trace'] as $trace) { + $content .= ' <li>'; + if ($trace['function']) { + $content .= sprintf('at %s%s%s(%s)', $this->abbrClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args'])); + } + if (isset($trace['file']) && isset($trace['line'])) { + if ($linkFormat = ini_get('xdebug.file_link_format')) { + $link = str_replace(array('%f', '%l'), array($trace['file'], $trace['line']), $linkFormat); + $content .= sprintf(' in <a href="%s" title="Go to source">%s line %s</a>', $link, $trace['file'], $trace['line']); + } else { + $content .= sprintf(' in %s line %s', $trace['file'], $trace['line']); + } + } + $content .= "</li>\n"; + } + + $content .= " </ol>\n</div>\n"; + } + } catch (\Exception $e) { + // something nasty happened and we cannot throw an exception anymore + if ($this->debug) { + $title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($exception), $exception->getMessage()); + } else { + $title = 'Whoops, looks like something went wrong.'; + } + } + } + + return <<<EOF + <div id="sf-resetcontent" class="sf-reset"> + <h1>$title</h1> + $content + </div> +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 <<<EOF + .sf-reset { font: 11px Verdana, Arial, sans-serif; color: #333 } + .sf-reset .clear { clear:both; height:0; font-size:0; line-height:0; } + .sf-reset .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; } + .sf-reset .clear_fix { display:inline-block; } + .sf-reset * html .clear_fix { height:1%; } + .sf-reset .clear_fix { display:block; } + .sf-reset, .sf-reset .block { margin: auto } + .sf-reset abbr { border-bottom: 1px dotted #000; cursor: help; } + .sf-reset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px } + .sf-reset strong { font-weight:bold; } + .sf-reset a { color:#6c6159; } + .sf-reset a img { border:none; } + .sf-reset a:hover { text-decoration:underline; } + .sf-reset em { font-style:italic; } + .sf-reset h1, .sf-reset h2 { font: 20px Georgia, "Times New Roman", Times, serif } + .sf-reset h2 span { background-color: #fff; color: #333; padding: 6px; float: left; margin-right: 10px; } + .sf-reset .traces li { font-size:12px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; } + .sf-reset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px; + -webkit-border-bottom-right-radius: 16px; + -webkit-border-bottom-left-radius: 16px; + -moz-border-radius-bottomright: 16px; + -moz-border-radius-bottomleft: 16px; + border-bottom-right-radius: 16px; + border-bottom-left-radius: 16px; + border-bottom:1px solid #ccc; + border-right:1px solid #ccc; + border-left:1px solid #ccc; + } + .sf-reset .block_exception { background-color:#ddd; color: #333; padding:20px; + -webkit-border-top-left-radius: 16px; + -webkit-border-top-right-radius: 16px; + -moz-border-radius-topleft: 16px; + -moz-border-radius-topright: 16px; + border-top-left-radius: 16px; + border-top-right-radius: 16px; + border-top:1px solid #ccc; + border-right:1px solid #ccc; + border-left:1px solid #ccc; + overflow: hidden; + word-wrap: break-word; + } + .sf-reset li a { background:none; color:#868686; text-decoration:none; } + .sf-reset li a:hover { background:none; color:#313131; text-decoration:underline; } + .sf-reset ol { padding: 10px 0; } + .sf-reset h1 { background-color:#FFFFFF; padding: 15px 28px; margin-bottom: 20px; + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + border-radius: 10px; + border: 1px solid #ccc; + } +EOF; + } + + private function decorate($content, $css) + { + return <<<EOF +<!DOCTYPE html> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <meta name="robots" content="noindex,nofollow" /> + <style> + /* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */ + html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;} + + html { background: #eee; padding: 10px } + img { border: 0; } + #sf-resetcontent { width:970px; margin:0 auto; } + $css + </style> + </head> + <body> + $content + </body> +</html> +EOF; + } + + private function abbrClass($class) + { + $parts = explode('\\', $class); + + return sprintf("<abbr title=\"%s\">%s</abbr>", $class, array_pop($parts)); + } + + /** + * 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("<em>object</em>(%s)", $this->abbrClass($item[1])); + } elseif ('array' === $item[0]) { + $formattedValue = sprintf("<em>array</em>(%s)", is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]); + } elseif ('string' === $item[0]) { + $formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES | ENT_SUBSTITUTE, $this->charset)); + } elseif ('null' === $item[0]) { + $formattedValue = '<em>null</em>'; + } elseif ('boolean' === $item[0]) { + $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>'; + } elseif ('resource' === $item[0]) { + $formattedValue = '<em>resource</em>'; + } else { + $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES | ENT_SUBSTITUTE, $this->charset), true)); + } + + $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); + } + + return implode(', ', $result); + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/LICENSE b/core/vendor/symfony/debug/Symfony/Component/Debug/LICENSE new file mode 100644 index 000000000000..88a57f8d8da4 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2004-2013 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/core/vendor/symfony/debug/Symfony/Component/Debug/README.md b/core/vendor/symfony/debug/Symfony/Component/Debug/README.md new file mode 100644 index 000000000000..dd5bdca6bff6 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/README.md @@ -0,0 +1,40 @@ +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: + + use Symfony\Component\Debug\Debug; + + Debug::enable(); + +You can also use the tools individually: + + use Symfony\Component\Debug\ErrorHandler; + use Symfony\Component\Debug\ExceptionHandler; + + error_reporting(-1); + + ErrorHandler::register($errorReportingLevel); + if ('cli' !== php_sapi_name()) { + ExceptionHandler::register(); + } elseif (!ini_get('log_errors') || ini_get('error_log')) { + ini_set('display_errors', 1); + } + +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.phar install --dev + $ phpunit diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ErrorHandlerTest.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/ErrorHandlerTest.php similarity index 96% rename from core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ErrorHandlerTest.php rename to core/vendor/symfony/debug/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 637c7ad376a0..db06f6107e6e 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ErrorHandlerTest.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpKernel\Tests\Debug; +namespace Symfony\Component\Debug\Tests; -use Symfony\Component\HttpKernel\Debug\ErrorHandler; +use Symfony\Component\Debug\ErrorHandler; /** * ErrorHandlerTest diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Exception/FlattenExceptionTest.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php similarity index 98% rename from core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Exception/FlattenExceptionTest.php rename to core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php index d51ab6aa0715..4a1d99e816a1 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Exception/FlattenExceptionTest.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpKernel\Tests\Exception; +namespace Symfony\Component\Debug\Tests\Exception; -use Symfony\Component\HttpKernel\Exception\FlattenException; +use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ExceptionHandlerTest.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php similarity index 95% rename from core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ExceptionHandlerTest.php rename to core/vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php index 4ccbe7dea4e4..f187e2d09929 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ExceptionHandlerTest.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpKernel\Tests\Debug; +namespace Symfony\Component\Debug\Tests; -use Symfony\Component\HttpKernel\Debug\ExceptionHandler; +use Symfony\Component\Debug\ExceptionHandler; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/composer.json b/core/vendor/symfony/debug/Symfony/Component/Debug/composer.json new file mode 100644 index 000000000000..35b170a3c0e1 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/composer.json @@ -0,0 +1,40 @@ +{ + "name": "symfony/debug", + "type": "library", + "description": "Symfony Debug Component", + "keywords": [], + "homepage": "http://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/http-kernel": "~2.1", + "symfony/http-foundation": "~2.1" + }, + "suggest": { + "symfony/http-foundation": "", + "symfony/http-kernel": "", + "symfony/class-loader": "" + }, + "autoload": { + "psr-0": { "Symfony\\Component\\Debug\\": "" } + }, + "target-dir": "Symfony/Component/Debug", + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist b/core/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist new file mode 100644 index 000000000000..8bab165e1053 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<phpunit backupGlobals="false" + backupStaticAttributes="false" + colors="true" + convertErrorsToExceptions="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" + processIsolation="false" + stopOnFailure="false" + syntaxCheck="false" + bootstrap="vendor/autoload.php" +> + <testsuites> + <testsuite name="Symfony Debug Component Test Suite"> + <directory>./Tests/</directory> + </testsuite> + </testsuites> + + <filter> + <whitelist> + <directory>./</directory> + <exclude> + <directory>./Tests</directory> + <directory>./vendor</directory> + </exclude> + </whitelist> + </filter> +</phpunit> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php index e24b5b020253..03528fefa9ef 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php @@ -56,11 +56,13 @@ public function process(ContainerBuilder $container) private function checkOutEdges(array $edges) { foreach ($edges as $edge) { - $node = $edge->getDestNode(); - $this->currentPath[] = $id = $node->getId(); + $node = $edge->getDestNode(); + $id = $node->getId(); + $searchKey = array_search($id, $this->currentPath); + $this->currentPath[] = $id; - if ($this->currentId === $id) { - throw new ServiceCircularReferenceException($this->currentId, $this->currentPath); + if (false !== $searchKey) { + throw new ServiceCircularReferenceException($id, array_slice($this->currentPath, $searchKey)); } $this->checkOutEdges($node->getOutEdges()); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php index 436dc74adbf1..9351b11b39dc 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php @@ -72,8 +72,8 @@ public function process(ContainerBuilder $container) $this->currentScopeChildren = array_keys($scopes); $this->currentScopeAncestors = array(); } elseif (ContainerInterface::SCOPE_PROTOTYPE !== $scope) { - $this->currentScopeChildren = $children[$scope]; - $this->currentScopeAncestors = $ancestors[$scope]; + $this->currentScopeChildren = isset($children[$scope]) ? $children[$scope] : array(); + $this->currentScopeAncestors = isset($ancestors[$scope]) ? $ancestors[$scope] : array(); } $this->validateReferences($definition->getArguments()); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php index 6fad9a284165..93d5806036bd 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php @@ -88,9 +88,7 @@ private function processArguments(array $arguments, $inMethodCall = false) $exists = $this->container->has($id); // resolve invalid behavior - if ($exists && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { - $arguments[$k] = new Reference($id, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $argument->isStrict()); - } elseif (!$exists && ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) { + if (!$exists && ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) { $arguments[$k] = null; } elseif (!$exists && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) { if ($inMethodCall) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php index 8a2c1b3a1ed9..ef561e1dedca 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection; +use Symfony\Component\DependencyInjection\Exception\InactiveScopeException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; @@ -67,6 +68,8 @@ class Container implements IntrospectableContainerInterface protected $parameterBag; protected $services; + protected $methodMap; + protected $aliases; protected $scopes; protected $scopeChildren; protected $scopedServices; @@ -206,6 +209,10 @@ public function set($id, $service, $scope = self::SCOPE_CONTAINER) } $this->services[$id] = $service; + + if (method_exists($this, $method = 'synchronize'.strtr($id, array('_' => '', '.' => '_')).'Service')) { + $this->$method(); + } } /** @@ -221,7 +228,7 @@ public function has($id) { $id = strtolower($id); - return isset($this->services[$id]) || method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_')).'Service'); + return array_key_exists($id, $this->services) || method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_')).'Service'); } /** @@ -247,7 +254,13 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE { $id = strtolower($id); - if (isset($this->services[$id])) { + // resolve aliases + if (isset($this->aliases[$id])) { + $id = $this->aliases[$id]; + } + + // re-use shared service instance if it exists + if (array_key_exists($id, $this->services)) { return $this->services[$id]; } @@ -255,29 +268,51 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE throw new ServiceCircularReferenceException($id, array_keys($this->loading)); } - if (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')) { - $this->loading[$id] = true; - - try { - $service = $this->$method(); - } catch (\Exception $e) { - unset($this->loading[$id]); + if (isset($this->methodMap[$id])) { + $method = $this->methodMap[$id]; + } elseif (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')) { + // $method is set to the right value, proceed + } else { + if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) { + if (!$id) { + throw new ServiceNotFoundException($id); + } - if (isset($this->services[$id])) { - unset($this->services[$id]); + $alternatives = array(); + foreach (array_keys($this->services) as $key) { + $lev = levenshtein($id, $key); + if ($lev <= strlen($id) / 3 || false !== strpos($key, $id)) { + $alternatives[] = $key; + } } - throw $e; + throw new ServiceNotFoundException($id, null, null, $alternatives); } + return null; + } + + $this->loading[$id] = true; + + try { + $service = $this->$method(); + } catch (\Exception $e) { unset($this->loading[$id]); - return $service; - } + if (array_key_exists($id, $this->services)) { + unset($this->services[$id]); + } + + if ($e instanceof InactiveScopeException && self::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { + return null; + } - if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) { - throw new ServiceNotFoundException($id); + throw $e; } + + unset($this->loading[$id]); + + return $service; } /** @@ -289,7 +324,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE */ public function initialized($id) { - return isset($this->services[strtolower($id)]); + return array_key_exists(strtolower($id), $this->services); } /** @@ -393,8 +428,11 @@ public function leaveScope($name) $services = $this->scopeStacks[$name]->pop(); $this->scopedServices += $services; - array_unshift($services, $this->services); - $this->services = call_user_func_array('array_merge', $services); + foreach ($services as $array) { + foreach ($array as $id => $service) { + $this->set($id, $service, $name); + } + } } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php index 5b178714bffe..733d016d6608 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -15,12 +15,15 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\Exception\BadMethodCallException; +use Symfony\Component\DependencyInjection\Exception\InactiveScopeException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\Config\Resource\ResourceInterface; +use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface; +use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\RealServiceInstantiator; /** * ContainerBuilder is a DI container that provides an API to easily describe services. @@ -46,10 +49,15 @@ class ContainerBuilder extends Container implements TaggedContainerInterface */ private $definitions = array(); + /** + * @var Definition[] + */ + private $obsoleteDefinitions = array(); + /** * @var Alias[] */ - private $aliases = array(); + private $aliasDefinitions = array(); /** * @var ResourceInterface[] @@ -65,6 +73,11 @@ class ContainerBuilder extends Container implements TaggedContainerInterface private $trackResources = true; + /** + * @var InstantiatorInterface|null + */ + private $proxyInstantiator; + /** * Sets the track resources flag. * @@ -88,6 +101,16 @@ public function isTrackingResources() return $this->trackResources; } + /** + * Sets the instantiator to be used when fetching proxies. + * + * @param InstantiatorInterface $proxyInstantiator + */ + public function setProxyInstantiator(InstantiatorInterface $proxyInstantiator) + { + $this->proxyInstantiator = $proxyInstantiator; + } + /** * Registers an extension. * @@ -216,15 +239,30 @@ public function setResources(array $resources) * @api */ public function addObjectResource($object) + { + if ($this->trackResources) { + $this->addClassResource(new \ReflectionClass($object)); + } + + return $this; + } + + /** + * Adds the given class hierarchy as resources. + * + * @param \ReflectionClass $class + * + * @return ContainerBuilder The current instance + */ + public function addClassResource(\ReflectionClass $class) { if (!$this->trackResources) { return $this; } - $parent = new \ReflectionObject($object); do { - $this->addResource(new FileResource($parent->getFileName())); - } while ($parent = $parent->getParentClass()); + $this->addResource(new FileResource($class->getFileName())); + } while ($class = $class->getParentClass()); return $this; } @@ -351,14 +389,28 @@ public function set($id, $service, $scope = self::SCOPE_CONTAINER) if ($this->isFrozen()) { // setting a synthetic service on a frozen container is alright - if (!isset($this->definitions[$id]) || !$this->definitions[$id]->isSynthetic()) { + if ( + (!isset($this->definitions[$id]) && !isset($this->obsoleteDefinitions[$id])) + || + (isset($this->definitions[$id]) && !$this->definitions[$id]->isSynthetic()) + || + (isset($this->obsoleteDefinitions[$id]) && !$this->obsoleteDefinitions[$id]->isSynthetic()) + ) { throw new BadMethodCallException(sprintf('Setting service "%s" on a frozen container is not allowed.', $id)); } } - unset($this->definitions[$id], $this->aliases[$id]); + if (isset($this->definitions[$id])) { + $this->obsoleteDefinitions[$id] = $this->definitions[$id]; + } + + unset($this->definitions[$id], $this->aliasDefinitions[$id]); parent::set($id, $service, $scope); + + if (isset($this->obsoleteDefinitions[$id]) && $this->obsoleteDefinitions[$id]->isSynchronized()) { + $this->synchronize($id); + } } /** @@ -386,7 +438,7 @@ public function has($id) { $id = strtolower($id); - return isset($this->definitions[$id]) || isset($this->aliases[$id]) || parent::has($id); + return isset($this->definitions[$id]) || isset($this->aliasDefinitions[$id]) || parent::has($id); } /** @@ -397,8 +449,10 @@ public function has($id) * * @return object The associated service * - * @throws InvalidArgumentException if the service is not defined - * @throws LogicException if the service has a circular reference to itself + * @throws InvalidArgumentException when no definitions are available + * @throws InactiveScopeException when the current scope is not active + * @throws LogicException when a circular dependency is detected + * @throws \Exception * * @see Reference * @@ -410,13 +464,19 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV try { return parent::get($id, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE); + } catch (InactiveScopeException $e) { + if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { + return null; + } + + throw $e; } catch (InvalidArgumentException $e) { if (isset($this->loading[$id])) { throw new LogicException(sprintf('The service "%s" has a circular reference to itself.', $id), 0, $e); } - if (!$this->hasDefinition($id) && isset($this->aliases[$id])) { - return $this->get($this->aliases[$id]); + if (!$this->hasDefinition($id) && isset($this->aliasDefinitions[$id])) { + return $this->get($this->aliasDefinitions[$id]); } try { @@ -435,6 +495,11 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV $service = $this->createService($definition, $id); } catch (\Exception $e) { unset($this->loading[$id]); + + if ($e instanceof InactiveScopeException && self::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { + return null; + } + throw $e; } @@ -553,6 +618,12 @@ public function compile() foreach ($this->compiler->getPassConfig()->getPasses() as $pass) { $this->addObjectResource($pass); } + + foreach ($this->definitions as $definition) { + if ($definition->isLazy() && ($class = $definition->getClass()) && class_exists($class)) { + $this->addClassResource(new \ReflectionClass($class)); + } + } } $this->compiler->compile($this); @@ -569,7 +640,7 @@ public function compile() */ public function getServiceIds() { - return array_unique(array_merge(array_keys($this->getDefinitions()), array_keys($this->aliases), parent::getServiceIds())); + return array_unique(array_merge(array_keys($this->getDefinitions()), array_keys($this->aliasDefinitions), parent::getServiceIds())); } /** @@ -595,7 +666,7 @@ public function addAliases(array $aliases) */ public function setAliases(array $aliases) { - $this->aliases = array(); + $this->aliasDefinitions = array(); $this->addAliases($aliases); } @@ -621,12 +692,12 @@ public function setAlias($alias, $id) } if ($alias === strtolower($id)) { - throw new InvalidArgumentException('An alias can not reference itself, got a circular reference on "'.$alias.'".'); + throw new InvalidArgumentException(sprintf('An alias can not reference itself, got a circular reference on "%s".', $alias)); } unset($this->definitions[$alias]); - $this->aliases[$alias] = $id; + $this->aliasDefinitions[$alias] = $id; } /** @@ -638,7 +709,7 @@ public function setAlias($alias, $id) */ public function removeAlias($alias) { - unset($this->aliases[strtolower($alias)]); + unset($this->aliasDefinitions[strtolower($alias)]); } /** @@ -652,7 +723,7 @@ public function removeAlias($alias) */ public function hasAlias($id) { - return isset($this->aliases[strtolower($id)]); + return isset($this->aliasDefinitions[strtolower($id)]); } /** @@ -664,7 +735,7 @@ public function hasAlias($id) */ public function getAliases() { - return $this->aliases; + return $this->aliasDefinitions; } /** @@ -686,7 +757,7 @@ public function getAlias($id) throw new InvalidArgumentException(sprintf('The service alias "%s" does not exist.', $id)); } - return $this->aliases[$id]; + return $this->aliasDefinitions[$id]; } /** @@ -766,7 +837,7 @@ public function setDefinition($id, Definition $definition) $id = strtolower($id); - unset($this->aliases[$id]); + unset($this->aliasDefinitions[$id]); return $this->definitions[$id] = $definition; } @@ -834,6 +905,7 @@ public function findDefinition($id) * * @param Definition $definition A service definition instance * @param string $id The service identifier + * @param Boolean $tryProxy Whether to try proxying the service with a lazy proxy * * @return object The service described by the service definition * @@ -841,13 +913,32 @@ public function findDefinition($id) * @throws RuntimeException When the factory definition is incomplete * @throws RuntimeException When the service is a synthetic service * @throws InvalidArgumentException When configure callable is not callable + * + * @internal this method is public because of PHP 5.3 limitations, do not use it explicitly in your code */ - private function createService(Definition $definition, $id) + public function createService(Definition $definition, $id, $tryProxy = true) { if ($definition->isSynthetic()) { throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The DIC does not know how to construct this service.', $id)); } + if ($tryProxy && $definition->isLazy()) { + $container = $this; + + $proxy = $this + ->getProxyInstantiator() + ->instantiateProxy( + $container, + $definition, + $id, function () use ($definition, $id, $container) { + return $container->createService($definition, $id, false); + } + ); + $this->shareService($definition, $proxy, $id); + + return $proxy; + } + $parameterBag = $this->getParameterBag(); if (null !== $definition->getFile()) { @@ -872,32 +963,13 @@ private function createService(Definition $definition, $id) $service = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs($arguments); } - if (self::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) { - if (self::SCOPE_CONTAINER !== $scope && !isset($this->scopedServices[$scope])) { - throw new RuntimeException(sprintf('You tried to create the "%s" service of an inactive scope.', $id)); - } - - $this->services[$lowerId = strtolower($id)] = $service; - - if (self::SCOPE_CONTAINER !== $scope) { - $this->scopedServices[$scope][$lowerId] = $service; - } + if ($tryProxy || !$definition->isLazy()) { + // share only if proxying failed, or if not a proxy + $this->shareService($definition, $service, $id); } foreach ($definition->getMethodCalls() as $call) { - $services = self::getServiceConditionals($call[1]); - - $ok = true; - foreach ($services as $s) { - if (!$this->has($s)) { - $ok = false; - break; - } - } - - if ($ok) { - call_user_func_array(array($service, $call[0]), $this->resolveServices($parameterBag->resolveValue($call[1]))); - } + $this->callMethod($service, $call); } $properties = $this->resolveServices($parameterBag->resolveValue($definition->getProperties())); @@ -945,9 +1017,20 @@ public function resolveServices($value) /** * Returns service ids for a given tag. * + * Example: + * + * $container->register('foo')->addTag('my.tag', array('hello' => 'world')); + * + * $serviceIds = $container->findTaggedServiceIds('my.tag'); + * foreach ($serviceIds as $serviceId => $tags) { + * foreach ($tags as $tag) { + * echo $tag['hello']; + * } + * } + * * @param string $name The tag name * - * @return array An array of tags + * @return array An array of tags with the tagged service as key, holding a list of attribute arrays. * * @api */ @@ -955,7 +1038,7 @@ public function findTaggedServiceIds($name) { $tags = array(); foreach ($this->getDefinitions() as $id => $definition) { - if ($definition->getTag($name)) { + if ($definition->hasTag($name)) { $tags[$id] = $definition->getTag($name); } } @@ -999,4 +1082,81 @@ public static function getServiceConditionals($value) return $services; } + + /** + * Retrieves the currently set proxy instantiator or instantiates one. + * + * @return InstantiatorInterface + */ + private function getProxyInstantiator() + { + if (!$this->proxyInstantiator) { + $this->proxyInstantiator = new RealServiceInstantiator(); + } + + return $this->proxyInstantiator; + } + + /** + * Synchronizes a service change. + * + * This method updates all services that depend on the given + * service by calling all methods referencing it. + * + * @param string $id A service id + */ + private function synchronize($id) + { + foreach ($this->definitions as $definitionId => $definition) { + // only check initialized services + if (!$this->initialized($definitionId)) { + continue; + } + + foreach ($definition->getMethodCalls() as $call) { + foreach ($call[1] as $argument) { + if ($argument instanceof Reference && $id == (string) $argument) { + $this->callMethod($this->get($definitionId), $call); + } + } + } + } + } + + private function callMethod($service, $call) + { + $services = self::getServiceConditionals($call[1]); + + foreach ($services as $s) { + if (!$this->has($s)) { + return; + } + } + + call_user_func_array(array($service, $call[0]), $this->resolveServices($this->getParameterBag()->resolveValue($call[1]))); + } + + /** + * Shares a given service in the container + * + * @param Definition $definition + * @param mixed $service + * @param string $id + * + * @throws InactiveScopeException + */ + private function shareService(Definition $definition, $service, $id) + { + if (self::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) { + if (self::SCOPE_CONTAINER !== $scope && !isset($this->scopedServices[$scope])) { + throw new InactiveScopeException($id, $scope); + } + + $this->services[$lowerId = strtolower($id)] = $service; + + if (self::SCOPE_CONTAINER !== $scope) { + $this->scopedServices[$scope][$lowerId] = $service; + } + } + } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Definition.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Definition.php index 359553a0bf46..1168444389ef 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Definition.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Definition.php @@ -36,6 +36,8 @@ class Definition private $public; private $synthetic; private $abstract; + private $synchronized; + private $lazy; protected $arguments; @@ -56,6 +58,8 @@ public function __construct($class = null, array $arguments = array()) $this->tags = array(); $this->public = true; $this->synthetic = false; + $this->synchronized = false; + $this->lazy = false; $this->abstract = false; $this->properties = array(); } @@ -569,6 +573,58 @@ public function isPublic() return $this->public; } + /** + * Sets the synchronized flag of this service. + * + * @param Boolean $boolean + * + * @return Definition The current instance + * + * @api + */ + public function setSynchronized($boolean) + { + $this->synchronized = (Boolean) $boolean; + + return $this; + } + + /** + * Whether this service is synchronized. + * + * @return Boolean + * + * @api + */ + public function isSynchronized() + { + return $this->synchronized; + } + + /** + * Sets the lazy flag of this service. + * + * @param Boolean $lazy + * + * @return Definition The current instance + */ + public function setLazy($lazy) + { + $this->lazy = (Boolean) $lazy; + + return $this; + } + + /** + * Whether this service is lazy. + * + * @return Boolean + */ + public function isLazy() + { + return $this->lazy; + } + /** * Sets whether this definition is synthetic, that is not constructed by the * container, but dynamically injected. diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 8ae9b616c5ef..0c622747cc54 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -21,6 +21,8 @@ use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; +use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface as ProxyDumper; +use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper; /** * PhpDumper dumps a service container as a PHP class. @@ -50,6 +52,11 @@ class PhpDumper extends Dumper private $variableCount; private $reservedVariables = array('instance', 'class'); + /** + * @var \Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface + */ + private $proxyDumper; + /** * {@inheritDoc} * @@ -62,6 +69,16 @@ public function __construct(ContainerBuilder $container) $this->inlinedDefinitions = new \SplObjectStorage; } + /** + * Sets the dumper to be used when dumping proxies in the generated container. + * + * @param ProxyDumper $proxyDumper + */ + public function setProxyDumper(ProxyDumper $proxyDumper) + { + $this->proxyDumper = $proxyDumper; + } + /** * Dumps the service container as a PHP class. * @@ -94,12 +111,27 @@ public function dump(array $options = array()) $code .= $this->addServices(). $this->addDefaultParametersMethod(). - $this->endClass() + $this->endClass(). + $this->addProxyClasses() ; return $code; } + /** + * Retrieves the currently set proxy dumper or instantiates one. + * + * @return ProxyDumper + */ + private function getProxyDumper() + { + if (!$this->proxyDumper) { + $this->proxyDumper = new NullDumper(); + } + + return $this->proxyDumper; + } + /** * Generates Service local temp variables. * @@ -149,6 +181,27 @@ private function addServiceLocalTempVariables($cId, $definition) return $code; } + /** + * Generates code for the proxies to be attached after the container class + * + * @return string + */ + private function addProxyClasses() + { + /* @var $proxyDefinitions Definition[] */ + $definitions = array_filter( + $this->container->getDefinitions(), + array($this->getProxyDumper(), 'isProxyCandidate') + ); + $code = ''; + + foreach ($definitions as $definition) { + $code .= "\n" . $this->getProxyDumper()->getProxyCode($definition); + } + + return $code; + } + /** * Generates the require_once statement for service includes. * @@ -280,12 +333,13 @@ private function addServiceInstance($id, $definition) throw new InvalidArgumentException(sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id)); } - $simple = $this->isSimpleInstance($id, $definition); + $simple = $this->isSimpleInstance($id, $definition); + $isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition); + $instantiation = ''; - $instantiation = ''; - if (ContainerInterface::SCOPE_CONTAINER === $definition->getScope()) { + if (!$isProxyCandidate && ContainerInterface::SCOPE_CONTAINER === $definition->getScope()) { $instantiation = "\$this->services['$id'] = ".($simple ? '' : '$instance'); - } elseif (ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) { + } elseif (!$isProxyCandidate && ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) { $instantiation = "\$this->services['$id'] = \$this->scopedServices['$scope']['$id'] = ".($simple ? '' : '$instance'); } elseif (!$simple) { $instantiation = '$instance'; @@ -441,19 +495,30 @@ private function addService($id, $definition) $this->referenceVariables = array(); $this->variableCount = 0; - $return = ''; + $return = array(); + if ($definition->isSynthetic()) { - $return = sprintf('@throws RuntimeException always since this service is expected to be injected dynamically'); + $return[] = '@throws RuntimeException always since this service is expected to be injected dynamically'; } elseif ($class = $definition->getClass()) { - $return = sprintf("@return %s A %s instance.", 0 === strpos($class, '%') ? 'Object' : $class, $class); + $return[] = sprintf("@return %s A %s instance.", 0 === strpos($class, '%') ? 'object' : $class, $class); } elseif ($definition->getFactoryClass()) { - $return = sprintf('@return Object An instance returned by %s::%s().', $definition->getFactoryClass(), $definition->getFactoryMethod()); + $return[] = sprintf('@return object An instance returned by %s::%s().', $definition->getFactoryClass(), $definition->getFactoryMethod()); } elseif ($definition->getFactoryService()) { - $return = sprintf('@return Object An instance returned by %s::%s().', $definition->getFactoryService(), $definition->getFactoryMethod()); + $return[] = sprintf('@return object An instance returned by %s::%s().', $definition->getFactoryService(), $definition->getFactoryMethod()); + } + + $scope = $definition->getScope(); + if (!in_array($scope, array(ContainerInterface::SCOPE_CONTAINER, ContainerInterface::SCOPE_PROTOTYPE))) { + if ($return && 0 === strpos($return[count($return) - 1], '@return')) { + $return[] = ''; + } + $return[] = sprintf("@throws InactiveScopeException when the '%s' service is requested while the '%s' scope is not active", $id, $scope); } + $return = implode("\n * ", $return); + $doc = ''; - if (ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope()) { + if (ContainerInterface::SCOPE_PROTOTYPE !== $scope) { $doc .= <<<EOF * @@ -472,20 +537,32 @@ private function addService($id, $definition) EOF; } - $code = <<<EOF + if ($definition->isLazy()) { + $lazyInitialization = '$lazyLoad = true'; + $lazyInitializationDoc = "\n * @param boolean \$lazyLoad whether to try lazy-loading the service with a proxy\n *"; + } else { + $lazyInitialization = ''; + $lazyInitializationDoc = ''; + } + + // with proxies, for 5.3.3 compatibility, the getter must be public to be accessible to the initializer + $isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition); + $visibility = $isProxyCandidate ? 'public' : 'protected'; + $code = <<<EOF /** * Gets the '$id' service.$doc - * + *$lazyInitializationDoc * $return */ - protected function get{$name}Service() + {$visibility} function get{$name}Service($lazyInitialization) { EOF; - $scope = $definition->getScope(); - if (ContainerInterface::SCOPE_CONTAINER !== $scope && ContainerInterface::SCOPE_PROTOTYPE !== $scope) { + $code .= $isProxyCandidate ? $this->getProxyDumper()->getProxyFactoryCode($definition, $id) : ''; + + if (!in_array($scope, array(ContainerInterface::SCOPE_CONTAINER, ContainerInterface::SCOPE_PROTOTYPE))) { $code .= <<<EOF if (!isset(\$this->scopedServices['$scope'])) { throw new InactiveScopeException('$id', '$scope'); @@ -518,63 +595,79 @@ protected function get{$name}Service() } /** - * Adds a service alias. - * - * @param string $alias - * @param string $id + * Adds multiple services * * @return string */ - private function addServiceAlias($alias, $id) + private function addServices() { - $name = Container::camelize($alias); - $type = 'Object'; + $publicServices = $privateServices = $synchronizers = ''; + $definitions = $this->container->getDefinitions(); + ksort($definitions); + foreach ($definitions as $id => $definition) { + if ($definition->isPublic()) { + $publicServices .= $this->addService($id, $definition); + } else { + $privateServices .= $this->addService($id, $definition); + } - if ($this->container->hasDefinition($id)) { - $class = $this->container->getDefinition($id)->getClass(); - $type = 0 === strpos($class, '%') ? 'Object' : $class; + $synchronizers .= $this->addServiceSynchronizer($id, $definition); } - return <<<EOF + return $publicServices.$synchronizers.$privateServices; + } /** - * Gets the $alias service alias. + * Adds synchronizer methods. * - * @return $type An instance of the $id service + * @param string $id A service identifier + * @param Definition $definition A Definition instance */ - protected function get{$name}Service() + private function addServiceSynchronizer($id, Definition $definition) { - return {$this->getServiceCall($id)}; - } + if (!$definition->isSynchronized()) { + return; + } -EOF; - } + $code = ''; + foreach ($this->container->getDefinitions() as $definitionId => $definition) { + foreach ($definition->getMethodCalls() as $call) { + foreach ($call[1] as $argument) { + if ($argument instanceof Reference && $id == (string) $argument) { + $arguments = array(); + foreach ($call[1] as $value) { + $arguments[] = $this->dumpValue($value); + } + + $call = $this->wrapServiceConditionals($call[1], sprintf("\$this->get('%s')->%s(%s);", $definitionId, $call[0], implode(', ', $arguments))); + + $code .= <<<EOF + if (\$this->initialized('$definitionId')) { + $call + } - /** - * Adds multiple services - * - * @return string - */ - private function addServices() - { - $publicServices = $privateServices = $aliasServices = ''; - $definitions = $this->container->getDefinitions(); - ksort($definitions); - foreach ($definitions as $id => $definition) { - if ($definition->isPublic()) { - $publicServices .= $this->addService($id, $definition); - } else { - $privateServices .= $this->addService($id, $definition); +EOF; + } + } } } - $aliases = $this->container->getAliases(); - ksort($aliases); - foreach ($aliases as $alias => $id) { - $aliasServices .= $this->addServiceAlias($alias, $id); + if (!$code) { + return; } - return $publicServices.$aliasServices.$privateServices; + $name = Container::camelize($id); + + return <<<EOF + + /** + * Updates the '$id' service. + */ + protected function synchronize{$name}Service() + { +$code } + +EOF; } private function addNewInstance($id, Definition $definition, $return, $instantiation) @@ -595,7 +688,7 @@ private function addNewInstance($id, Definition $definition, $return, $instantia return sprintf(" $return{$instantiation}%s->%s(%s);\n", $this->getServiceCall($definition->getFactoryService()), $definition->getFactoryMethod(), implode(', ', $arguments)); } - throw new RuntimeException('Factory method requires a factory service or factory class in service definition for '.$id); + throw new RuntimeException(sprintf('Factory method requires a factory service or factory class in service definition for %s', $id)); } if (false !== strpos($class, '$')) { @@ -667,6 +760,9 @@ public function __construct() $code .= " \$this->scopeChildren = ".$this->dumpValue($this->container->getScopeChildren()).";\n"; } + $code .= $this->addMethodMap(); + $code .= $this->addAliases(); + $code .= <<<EOF } @@ -714,6 +810,9 @@ public function __construct() $code .= " \$this->scopeChildren = array();\n"; } + $code .= $this->addMethodMap(); + $code .= $this->addAliases(); + $code .= <<<EOF } @@ -722,6 +821,50 @@ public function __construct() return $code; } + /** + * Adds the methodMap property definition + * + * @return string + */ + private function addMethodMap() + { + if (!$definitions = $this->container->getDefinitions()) { + return ''; + } + + $code = " \$this->methodMap = array(\n"; + ksort($definitions); + foreach ($definitions as $id => $definition) { + $code .= ' '.var_export($id, true).' => '.var_export('get'.Container::camelize($id).'Service', true).",\n"; + } + + return $code . " );\n"; + } + + /** + * Adds the aliases property definition + * + * @return string + */ + private function addAliases() + { + if (!$aliases = $this->container->getAliases()) { + return ''; + } + + $code = " \$this->aliases = array(\n"; + ksort($aliases); + foreach ($aliases as $alias => $id) { + $id = (string) $id; + while (isset($aliases[$id])) { + $id = (string) $aliases[$id]; + } + $code .= ' '.var_export($alias, true).' => '.var_export($id, true).",\n"; + } + + return $code . " );\n"; + } + /** * Adds default parameters method. * @@ -874,7 +1017,7 @@ private function wrapServiceConditionals($value, $code) } /** - * Builds service calls from arguments + * Builds service calls from arguments. * * @param array $arguments * @param array &$calls By reference @@ -903,7 +1046,7 @@ private function getServiceCallsFromArguments(array $arguments, array &$calls, a } /** - * Returns the inline definition + * Returns the inline definition. * * @param Definition $definition * @@ -927,7 +1070,7 @@ private function getInlinedDefinitions(Definition $definition) } /** - * Gets the definition from arguments + * Gets the definition from arguments. * * @param array $arguments * @@ -952,11 +1095,12 @@ private function getDefinitionsFromArguments(array $arguments) } /** - * Checks if a service id has a reference + * Checks if a service id has a reference. * * @param string $id * @param array $arguments * @param Boolean $deep + * @param array $visited * * @return Boolean */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php index 38025ff3eac8..a311af348e34 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php @@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\Parameter; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Exception\RuntimeException; /** @@ -127,6 +128,15 @@ private function addService($definition, $id, \DOMElement $parent) if (!$definition->isPublic()) { $service->setAttribute('public', 'false'); } + if ($definition->isSynthetic()) { + $service->setAttribute('synthetic', 'true'); + } + if ($definition->isSynchronized()) { + $service->setAttribute('synchronized', 'true'); + } + if ($definition->isLazy()) { + $service->setAttribute('lazy', 'true'); + } foreach ($definition->getTags() as $name => $tags) { foreach ($tags as $attributes) { @@ -173,10 +183,10 @@ private function addService($definition, $id, \DOMElement $parent) * Adds a service alias. * * @param string $alias - * @param string $id + * @param Alias $id * @param \DOMElement $parent */ - private function addServiceAlias($alias, $id, \DOMElement $parent) + private function addServiceAlias($alias, Alias $id, \DOMElement $parent) { $service = $this->document->createElement('service'); $service->setAttribute('id', $alias); @@ -204,7 +214,11 @@ private function addServices(\DOMElement $parent) $this->addService($definition, $id, $services); } - foreach ($this->container->getAliases() as $alias => $id) { + $aliases = $this->container->getAliases(); + foreach ($aliases as $alias => $id) { + while (isset($aliases[(string) $id])) { + $id = $aliases[(string) $id]; + } $this->addServiceAlias($alias, $id, $services); } $parent->appendChild($services); @@ -239,6 +253,9 @@ private function convertParameters($parameters, $type, \DOMElement $parent, $key } elseif ($behaviour == ContainerInterface::IGNORE_ON_INVALID_REFERENCE) { $element->setAttribute('on-invalid', 'ignore'); } + if (!$value->isStrict()) { + $element->setAttribute('strict', 'false'); + } } elseif ($value instanceof Definition) { $element->setAttribute('type', 'service'); $this->addService($value, null, $element); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index 0574df455e4a..807e656283b5 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -94,6 +94,22 @@ private function addService($id, $definition) $code .= sprintf(" file: %s\n", $definition->getFile()); } + if ($definition->isSynthetic()) { + $code .= sprintf(" synthetic: true\n"); + } + + if ($definition->isSynchronized()) { + $code .= sprintf(" synchronized: true\n"); + } + + if ($definition->getFactoryClass()) { + $code .= sprintf(" factory_class: %s\n", $definition->getFactoryClass()); + } + + if ($definition->isLazy()) { + $code .= sprintf(" lazy: true\n"); + } + if ($definition->getFactoryMethod()) { $code .= sprintf(" factory_method: %s\n", $definition->getFactoryMethod()); } @@ -166,7 +182,11 @@ private function addServices() $code .= $this->addService($id, $definition); } - foreach ($this->container->getAliases() as $alias => $id) { + $aliases = $this->container->getAliases(); + foreach ($aliases as $alias => $id) { + while (isset($aliases[(string) $id])) { + $id = $aliases[(string) $id]; + } $code .= $this->addServiceAlias($alias, $id); } @@ -248,9 +268,10 @@ private function getParameterCall($id) } /** - * Prepares parameters + * Prepares parameters. * - * @param array $parameters + * @param array $parameters + * @param Boolean $escape * * @return array */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/InactiveScopeException.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/InactiveScopeException.php index 24d1ca0547f7..6b3dd3ebb1ac 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/InactiveScopeException.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/InactiveScopeException.php @@ -21,9 +21,9 @@ class InactiveScopeException extends RuntimeException private $serviceId; private $scope; - public function __construct($serviceId, $scope) + public function __construct($serviceId, $scope, \Exception $previous = null) { - parent::__construct(sprintf('You cannot create a service ("%s") of an inactive scope ("%s").', $serviceId, $scope)); + parent::__construct(sprintf('You cannot create a service ("%s") of an inactive scope ("%s").', $serviceId, $scope), 0, $previous); $this->serviceId = $serviceId; $this->scope = $scope; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php index 958ade060c65..29151765dc5b 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php @@ -20,9 +20,9 @@ class ParameterCircularReferenceException extends RuntimeException { private $parameters; - public function __construct($parameters) + public function __construct($parameters, \Exception $previous = null) { - parent::__construct(sprintf('Circular reference detected for parameter "%s" ("%s" > "%s").', $parameters[0], implode('" > "', $parameters), $parameters[0])); + parent::__construct(sprintf('Circular reference detected for parameter "%s" ("%s" > "%s").', $parameters[0], implode('" > "', $parameters), $parameters[0]), 0, $previous); $this->parameters = $parameters; } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php index 200fbec2af2b..b529f0fe83d2 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php @@ -21,19 +21,25 @@ class ParameterNotFoundException extends InvalidArgumentException private $key; private $sourceId; private $sourceKey; + private $alternatives; /** * Constructor. * - * @param string $key The requested parameter key - * @param string $sourceId The service id that references the non-existent parameter - * @param string $sourceKey The parameter key that references the non-existent parameter + * @param string $key The requested parameter key + * @param string $sourceId The service id that references the non-existent parameter + * @param string $sourceKey The parameter key that references the non-existent parameter + * @param \Exception $previous The previous exception + * @param string[] $alternatives Some parameter name alternatives */ - public function __construct($key, $sourceId = null, $sourceKey = null) + public function __construct($key, $sourceId = null, $sourceKey = null, \Exception $previous = null, array $alternatives = array()) { $this->key = $key; $this->sourceId = $sourceId; $this->sourceKey = $sourceKey; + $this->alternatives = $alternatives; + + parent::__construct('', 0, $previous); $this->updateRepr(); } @@ -47,6 +53,15 @@ public function updateRepr() } else { $this->message = sprintf('You have requested a non-existent parameter "%s".', $this->key); } + + if ($this->alternatives) { + if (1 == count($this->alternatives)) { + $this->message .= ' Did you mean this: "'; + } else { + $this->message .= ' Did you mean one of these: "'; + } + $this->message .= implode('", "', $this->alternatives).'"?'; + } } public function getKey() diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ScopeCrossingInjectionException.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ScopeCrossingInjectionException.php index f23374f21085..661fbab3697f 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ScopeCrossingInjectionException.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ScopeCrossingInjectionException.php @@ -23,7 +23,7 @@ class ScopeCrossingInjectionException extends RuntimeException private $destServiceId; private $destScope; - public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope) + public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null) { parent::__construct(sprintf( 'Scope Crossing Injection detected: The definition "%s" references the service "%s" which belongs to another scope hierarchy. ' @@ -35,7 +35,7 @@ public function __construct($sourceServiceId, $sourceScope, $destServiceId, $des $destScope, $sourceScope, $destScope - )); + ), 0, $previous); $this->sourceServiceId = $sourceServiceId; $this->sourceScope = $sourceScope; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ScopeWideningInjectionException.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ScopeWideningInjectionException.php index d46345334ca6..86a668419510 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ScopeWideningInjectionException.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ScopeWideningInjectionException.php @@ -23,7 +23,7 @@ class ScopeWideningInjectionException extends RuntimeException private $destServiceId; private $destScope; - public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope) + public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null) { parent::__construct(sprintf( 'Scope Widening Injection detected: The definition "%s" references the service "%s" which belongs to a narrower scope. ' @@ -34,7 +34,7 @@ public function __construct($sourceServiceId, $sourceScope, $destServiceId, $des $sourceServiceId, $destScope, $destServiceId - )); + ), 0, $previous); $this->sourceServiceId = $sourceServiceId; $this->sourceScope = $sourceScope; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php index e0000011fc75..26e3fb34bf3c 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php @@ -21,9 +21,9 @@ class ServiceCircularReferenceException extends RuntimeException private $serviceId; private $path; - public function __construct($serviceId, array $path) + public function __construct($serviceId, array $path, \Exception $previous = null) { - parent::__construct(sprintf('Circular reference detected for service "%s", path: "%s".', $serviceId, implode(' -> ', $path))); + parent::__construct(sprintf('Circular reference detected for service "%s", path: "%s".', $serviceId, implode(' -> ', $path)), 0, $previous); $this->serviceId = $serviceId; $this->path = $path; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php index f9af1ea84e37..e65da506bb51 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php @@ -21,7 +21,7 @@ class ServiceNotFoundException extends InvalidArgumentException private $id; private $sourceId; - public function __construct($id, $sourceId = null) + public function __construct($id, $sourceId = null, \Exception $previous = null, array $alternatives = array()) { if (null === $sourceId) { $msg = sprintf('You have requested a non-existent service "%s".', $id); @@ -29,7 +29,16 @@ public function __construct($id, $sourceId = null) $msg = sprintf('The service "%s" has a dependency on a non-existent service "%s".', $sourceId, $id); } - parent::__construct($msg); + if ($alternatives) { + if (1 == count($alternatives)) { + $msg .= ' Did you mean this: "'; + } else { + $msg .= ' Did you mean one of these: "'; + } + $msg .= implode('", "', $alternatives).'"?'; + } + + parent::__construct($msg, 0, $previous); $this->id = $id; $this->sourceId = $sourceId; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/Extension.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/Extension.php index bc1eaa1ffac8..a39fe37ed4f0 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/Extension.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/Extension.php @@ -85,7 +85,7 @@ public function getConfiguration(array $config, ContainerBuilder $container) $reflected = new \ReflectionClass($this); $namespace = $reflected->getNamespaceName(); - $class = $namespace . '\\Configuration'; + $class = $namespace.'\\Configuration'; if (class_exists($class)) { $r = new \ReflectionClass($class); $container->addResource(new FileResource($r->getFileName())); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/InstantiatorInterface.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/InstantiatorInterface.php new file mode 100644 index 000000000000..a8dd5252ed28 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/InstantiatorInterface.php @@ -0,0 +1,37 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\LazyProxy\Instantiator; + +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Definition; + +/** + * Lazy proxy instantiator, capable of instantiating a proxy given a container, the + * service definitions and a callback that produces the real service instance. + * + * @author Marco Pivetta <ocramius@gmail.com> + */ +interface InstantiatorInterface +{ + /** + * Instantiates a proxy object. + * + * @param ContainerInterface $container the container from which the service is being requested + * @param Definition $definition the definition of the requested service + * @param string $id identifier of the requested service + * @param callable $realInstantiator zero-argument callback that is capable of producing the real + * service instance + * + * @return object + */ + public function instantiateProxy(ContainerInterface $container, Definition $definition, $id, $realInstantiator); +} diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/RealServiceInstantiator.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/RealServiceInstantiator.php new file mode 100644 index 000000000000..6495df2813db --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/RealServiceInstantiator.php @@ -0,0 +1,33 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\LazyProxy\Instantiator; + +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Definition; + +/** + * {@inheritDoc} + * + * Noop proxy instantiator - simply produces the real service instead of a proxy instance. + * + * @author Marco Pivetta <ocramius@gmail.com> + */ +class RealServiceInstantiator implements InstantiatorInterface +{ + /** + * {@inheritDoc} + */ + public function instantiateProxy(ContainerInterface $container, Definition $definition, $id, $realInstantiator) + { + return call_user_func($realInstantiator); + } +} diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php new file mode 100644 index 000000000000..d8d5dac47095 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php @@ -0,0 +1,51 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\LazyProxy\PhpDumper; + +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Definition; + +/** + * Lazy proxy dumper capable of generating the instantiation logic php code for proxied services. + * + * @author Marco Pivetta <ocramius@gmail.com> + */ +interface DumperInterface +{ + /** + * Inspects whether the given definitions should produce proxy instantiation logic in the dumped container. + * + * @param Definition $definition + * + * @return bool + */ + public function isProxyCandidate(Definition $definition); + + /** + * Generates the code to be used to instantiate a proxy in the dumped factory code. + * + * @param Definition $definition + * @param string $id service identifier + * + * @return string + */ + public function getProxyFactoryCode(Definition $definition, $id); + + /** + * Generates the code for the lazy proxy. + * + * @param Definition $definition + * + * @return string + */ + public function getProxyCode(Definition $definition); +} diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php new file mode 100644 index 000000000000..e1d4ff4dea90 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php @@ -0,0 +1,47 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\LazyProxy\PhpDumper; + +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Definition; + +/** + * Null dumper, negates any proxy code generation for any given service definition. + * + * @author Marco Pivetta <ocramius@gmail.com> + */ +class NullDumper implements DumperInterface +{ + /** + * {@inheritDoc} + */ + public function isProxyCandidate(Definition $definition) + { + return false; + } + + /** + * {@inheritDoc} + */ + public function getProxyFactoryCode(Definition $definition, $id) + { + return ''; + } + + /** + * {@inheritDoc} + */ + public function getProxyCode(Definition $definition) + { + return ''; + } +} diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index f925f78ab27e..9f25ab7683cd 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -148,7 +148,7 @@ private function parseDefinition($id, $service, $file) $definition = new Definition(); } - foreach (array('class', 'scope', 'public', 'factory-class', 'factory-method', 'factory-service', 'synthetic', 'abstract') as $key) { + foreach (array('class', 'scope', 'public', 'factory-class', 'factory-method', 'factory-service', 'synthetic', 'synchronized', 'lazy', 'abstract') as $key) { if (isset($service[$key])) { $method = 'set'.str_replace('-', '', $key); $definition->$method((string) $service->getAttributeAsPhp($key)); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 05215cdb6b9a..ce135fa81f92 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -18,7 +18,7 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Yaml\Yaml; +use Symfony\Component\Yaml\Parser as YamlParser; /** * YamlFileLoader loads YAML files service definitions. @@ -29,6 +29,8 @@ */ class YamlFileLoader extends FileLoader { + private $yamlParser; + /** * Loads a Yaml file. * @@ -153,6 +155,14 @@ private function parseDefinition($id, $service, $file) $definition->setSynthetic($service['synthetic']); } + if (isset($service['synchronized'])) { + $definition->setSynchronized($service['synchronized']); + } + + if (isset($service['lazy'])) { + $definition->setLazy($service['lazy']); + } + if (isset($service['public'])) { $definition->setPublic($service['public']); } @@ -235,7 +245,19 @@ private function parseDefinition($id, $service, $file) */ protected function loadFile($file) { - return $this->validate(Yaml::parse($file), $file); + if (!stream_is_local($file)) { + throw new InvalidArgumentException(sprintf('This is not a local file "%s".', $file)); + } + + if (!file_exists($file)) { + throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file)); + } + + if (null === $this->yamlParser) { + $this->yamlParser = new YamlParser(); + } + + return $this->validate($this->yamlParser->parse(file_get_contents($file)), $file); } /** diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd index 316f2d759687..f1c2003c6225 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd @@ -86,6 +86,8 @@ <xsd:attribute name="scope" type="xsd:string" /> <xsd:attribute name="public" type="boolean" /> <xsd:attribute name="synthetic" type="boolean" /> + <xsd:attribute name="synchronized" type="boolean" /> + <xsd:attribute name="lazy" type="boolean" /> <xsd:attribute name="abstract" type="boolean" /> <xsd:attribute name="factory-class" type="xsd:string" /> <xsd:attribute name="factory-method" type="xsd:string" /> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index 70f3956e3c9c..494d231e9f29 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -93,7 +93,19 @@ public function get($name) $name = strtolower($name); if (!array_key_exists($name, $this->parameters)) { - throw new ParameterNotFoundException($name); + if (!$name) { + throw new ParameterNotFoundException($name); + } + + $alternatives = array(); + foreach (array_keys($this->parameters) as $key) { + $lev = levenshtein($name, $key); + if ($lev <= strlen($name) / 3 || false !== strpos($key, $name)) { + $alternatives[] = $key; + } + } + + throw new ParameterNotFoundException($name, null, null, null, $alternatives); } return $this->parameters[$name]; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php index 25f816b834ac..085bc519b73e 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php @@ -24,7 +24,7 @@ class CheckCircularReferencesPassTest extends \PHPUnit_Framework_TestCase { /** - * @expectedException \RuntimeException + * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException */ public function testProcess() { @@ -36,7 +36,7 @@ public function testProcess() } /** - * @expectedException \RuntimeException + * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException */ public function testProcessWithAliases() { @@ -49,7 +49,7 @@ public function testProcessWithAliases() } /** - * @expectedException \RuntimeException + * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException */ public function testProcessDetectsIndirectCircularReference() { @@ -61,6 +61,19 @@ public function testProcessDetectsIndirectCircularReference() $this->process($container); } + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException + */ + public function testDeepCircularReference() + { + $container = new ContainerBuilder(); + $container->register('a')->addArgument(new Reference('b')); + $container->register('b')->addArgument(new Reference('c')); + $container->register('c')->addArgument(new Reference('b')); + + $this->process($container); + } + public function testProcessIgnoresMethodCalls() { $container = new ContainerBuilder(); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index bfd92798dc4c..a5e7531b68af 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -14,6 +14,7 @@ require_once __DIR__.'/Fixtures/includes/classes.php'; require_once __DIR__.'/Fixtures/includes/ProjectExtension.php'; +use Symfony\Component\Config\Resource\ResourceInterface; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -22,6 +23,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; +use Symfony\Component\DependencyInjection\Scope; use Symfony\Component\Config\Resource\FileResource; class ContainerBuilderTest extends \PHPUnit_Framework_TestCase @@ -137,6 +139,17 @@ public function testGetUnsetLoadingServiceWhenCreateServiceThrowsAnException() $builder->get('foo'); } + /** + * @covers Symfony\Component\DependencyInjection\ContainerBuilder::get + */ + public function testGetReturnsNullOnInactiveScope() + { + $builder = new ContainerBuilder(); + $builder->register('foo', 'stdClass')->setScope('request'); + + $this->assertNull($builder->get('foo', ContainerInterface::NULL_ON_INVALID_REFERENCE)); + } + /** * @covers Symfony\Component\DependencyInjection\ContainerBuilder::getServiceIds */ @@ -251,6 +264,22 @@ public function testCreateService() $this->assertInstanceOf('\FooClass', $builder->get('foo2'), '->createService() replaces parameters in the file provided by the service definition'); } + /** + * @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService + */ + public function testCreateProxyWithRealServiceInstantiator() + { + $builder = new ContainerBuilder(); + + $builder->register('foo1', 'FooClass')->setFile(__DIR__.'/Fixtures/includes/foo.php'); + $builder->getDefinition('foo1')->setLazy(true); + + $foo1 = $builder->get('foo1'); + + $this->assertSame($foo1, $builder->get('foo1'), 'The same proxy is retrieved on multiple subsequent calls'); + $this->assertSame('FooClass', get_class($foo1)); + } + /** * @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService */ @@ -453,6 +482,95 @@ public function testFindDefinition() $this->assertEquals($definition, $container->findDefinition('foobar'), '->findDefinition() returns a Definition'); } + /** + * @covers Symfony\Component\DependencyInjection\ContainerBuilder::addObjectResource + */ + public function testAddObjectResource() + { + if (!class_exists('Symfony\Component\Config\Resource\FileResource')) { + $this->markTestSkipped('The "Config" component is not available'); + } + + $container = new ContainerBuilder(); + + $container->setResourceTracking(false); + $container->addObjectResource(new \BarClass()); + + $this->assertEmpty($container->getResources(), 'No resources get registered without resource tracking'); + + $container->setResourceTracking(true); + $container->addObjectResource(new \BarClass()); + + $resources = $container->getResources(); + + $this->assertCount(1, $resources, '1 resource was registered'); + + /* @var $resource \Symfony\Component\Config\Resource\FileResource */ + $resource = end($resources); + + $this->assertInstanceOf('Symfony\Component\Config\Resource\FileResource', $resource); + $this->assertSame(realpath(__DIR__.'/Fixtures/includes/classes.php'), realpath($resource->getResource())); + } + + /** + * @covers Symfony\Component\DependencyInjection\ContainerBuilder::addClassResource + */ + public function testAddClassResource() + { + if (!class_exists('Symfony\Component\Config\Resource\FileResource')) { + $this->markTestSkipped('The "Config" component is not available'); + } + + $container = new ContainerBuilder(); + + $container->setResourceTracking(false); + $container->addClassResource(new \ReflectionClass('BarClass')); + + $this->assertEmpty($container->getResources(), 'No resources get registered without resource tracking'); + + $container->setResourceTracking(true); + $container->addClassResource(new \ReflectionClass('BarClass')); + + $resources = $container->getResources(); + + $this->assertCount(1, $resources, '1 resource was registered'); + + /* @var $resource \Symfony\Component\Config\Resource\FileResource */ + $resource = end($resources); + + $this->assertInstanceOf('Symfony\Component\Config\Resource\FileResource', $resource); + $this->assertSame(realpath(__DIR__.'/Fixtures/includes/classes.php'), realpath($resource->getResource())); + } + + /** + * @covers Symfony\Component\DependencyInjection\ContainerBuilder::compile + */ + public function testCompilesClassDefinitionsOfLazyServices() + { + if (!class_exists('Symfony\Component\Config\Resource\FileResource')) { + $this->markTestSkipped('The "Config" component is not available'); + } + + $container = new ContainerBuilder(); + + $this->assertEmpty($container->getResources(), 'No resources get registered without resource tracking'); + + $container->register('foo', 'BarClass'); + $container->getDefinition('foo')->setLazy(true); + + $container->compile(); + + $classesPath = realpath(__DIR__.'/Fixtures/includes/classes.php'); + $matchingResources = array_filter( + $container->getResources(), + function (ResourceInterface $resource) use ($classesPath) { + return $resource instanceof FileResource && $classesPath === realpath($resource->getResource()); + } + ); + + $this->assertNotEmpty($matchingResources); + } + /** * @covers Symfony\Component\DependencyInjection\ContainerBuilder::getResources * @covers Symfony\Component\DependencyInjection\ContainerBuilder::addResource @@ -577,6 +695,52 @@ public function testNoExceptionWhenSetSyntheticServiceOnAFrozenContainer() $this->assertEquals($a, $container->get('a')); } + public function testSetOnSynchronizedService() + { + $container = new ContainerBuilder(); + $container->register('baz', 'BazClass') + ->setSynchronized(true) + ; + $container->register('bar', 'BarClass') + ->addMethodCall('setBaz', array(new Reference('baz'))) + ; + + $container->set('baz', $baz = new \BazClass()); + $this->assertSame($baz, $container->get('bar')->getBaz()); + + $container->set('baz', $baz = new \BazClass()); + $this->assertSame($baz, $container->get('bar')->getBaz()); + } + + public function testSynchronizedServiceWithScopes() + { + $container = new ContainerBuilder(); + $container->addScope(new Scope('foo')); + $container->register('baz', 'BazClass') + ->setSynthetic(true) + ->setSynchronized(true) + ->setScope('foo') + ; + $container->register('bar', 'BarClass') + ->addMethodCall('setBaz', array(new Reference('baz', ContainerInterface::NULL_ON_INVALID_REFERENCE, false))) + ; + $container->compile(); + + $container->enterScope('foo'); + $container->set('baz', $outerBaz = new \BazClass(), 'foo'); + $this->assertSame($outerBaz, $container->get('bar')->getBaz()); + + $container->enterScope('foo'); + $container->set('baz', $innerBaz = new \BazClass(), 'foo'); + $this->assertSame($innerBaz, $container->get('bar')->getBaz()); + $container->leaveScope('foo'); + + $this->assertNotSame($innerBaz, $container->get('bar')->getBaz()); + $this->assertSame($outerBaz, $container->get('bar')->getBaz()); + + $container->leaveScope('foo'); + } + /** * @expectedException BadMethodCallException */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index 23c13c5094cb..f49a567f527f 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; +use Symfony\Component\DependencyInjection\Exception\InactiveScopeException; class ContainerTest extends \PHPUnit_Framework_TestCase { @@ -98,7 +99,7 @@ public function testGetServiceIds() $this->assertEquals(array('service_container', 'foo', 'bar'), $sc->getServiceIds(), '->getServiceIds() returns all defined service ids'); $sc = new ProjectServiceContainer(); - $this->assertEquals(array('scoped', 'scoped_foo', 'bar', 'foo_bar', 'foo.baz', 'circular', 'throw_exception', 'throws_exception_on_service_configuration', 'service_container'), $sc->getServiceIds(), '->getServiceIds() returns defined service ids by getXXXService() methods'); + $this->assertEquals(array('scoped', 'scoped_foo', 'inactive', 'bar', 'foo_bar', 'foo.baz', 'circular', 'throw_exception', 'throws_exception_on_service_configuration', 'service_container'), $sc->getServiceIds(), '->getServiceIds() returns defined service ids by getXXXService() methods'); } /** @@ -166,6 +167,30 @@ public function testGet() $this->assertNull($sc->get('', ContainerInterface::NULL_ON_INVALID_REFERENCE)); } + public function testGetThrowServiceNotFoundException() + { + $sc = new ProjectServiceContainer(); + $sc->set('foo', $foo = new \stdClass()); + $sc->set('bar', $foo = new \stdClass()); + $sc->set('baz', $foo = new \stdClass()); + + try { + $sc->get('foo1'); + $this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist'); + $this->assertEquals('You have requested a non-existent service "foo1". Did you mean this: "foo"?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException with some advices'); + } + + try { + $sc->get('bag'); + $this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist'); + $this->assertEquals('You have requested a non-existent service "bag". Did you mean one of these: "bar", "baz"?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException with some advices'); + } + } + public function testGetCircularReference() { @@ -179,6 +204,15 @@ public function testGetCircularReference() } } + /** + * @covers Symfony\Component\DependencyInjection\Container::get + */ + public function testGetReturnsNullOnInactiveScope() + { + $sc = new ProjectServiceContainer(); + $this->assertNull($sc->get('inactive', ContainerInterface::NULL_ON_INVALID_REFERENCE)); + } + /** * @covers Symfony\Component\DependencyInjection\Container::has */ @@ -476,6 +510,11 @@ protected function getScopedFooService() return $this->services['scoped_foo'] = $this->scopedServices['foo']['scoped_foo'] = new \stdClass(); } + protected function getInactiveService() + { + throw new InactiveScopeException('request', 'request'); + } + protected function getBarService() { return $this->__bar; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php index 89f7ae1ea0ad..d41c6a8e2b2a 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php @@ -149,7 +149,31 @@ public function testSetIsSynthetic() $def = new Definition('stdClass'); $this->assertFalse($def->isSynthetic(), '->isSynthetic() returns false by default'); $this->assertSame($def, $def->setSynthetic(true), '->setSynthetic() implements a fluent interface'); - $this->assertTrue($def->isSynthetic(), '->isSynthetic() returns true if the instance must not be public.'); + $this->assertTrue($def->isSynthetic(), '->isSynthetic() returns true if the service is synthetic.'); + } + + /** + * @covers Symfony\Component\DependencyInjection\Definition::setSynchronized + * @covers Symfony\Component\DependencyInjection\Definition::isSynchronized + */ + public function testSetIsSynchronized() + { + $def = new Definition('stdClass'); + $this->assertFalse($def->isSynchronized(), '->isSynchronized() returns false by default'); + $this->assertSame($def, $def->setSynchronized(true), '->setSynchronized() implements a fluent interface'); + $this->assertTrue($def->isSynchronized(), '->isSynchronized() returns true if the service is synchronized.'); + } + + /** + * @covers Symfony\Component\DependencyInjection\Definition::setLazy + * @covers Symfony\Component\DependencyInjection\Definition::isLazy + */ + public function testSetIsLazy() + { + $def = new Definition('stdClass'); + $this->assertFalse($def->isLazy(), '->isLazy() returns false by default'); + $this->assertSame($def, $def->setLazy(true), '->setLazy() implements a fluent interface'); + $this->assertTrue($def->isLazy(), '->isLazy() returns true if the service is lazy.'); } /** diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 72d587ff070f..0ea42d473b0f 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -120,6 +120,20 @@ public function testAddService() } } + public function testAliases() + { + $container = include self::$fixturesPath.'/containers/container9.php'; + $container->compile(); + $dumper = new PhpDumper($container); + eval('?>'.$dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Aliases'))); + + $container = new \Symfony_DI_PhpDumper_Test_Aliases(); + $container->set('foo', $foo = new \stdClass); + $this->assertSame($foo, $container->get('foo')); + $this->assertSame($foo, $container->get('alias_for_foo')); + $this->assertSame($foo, $container->get('alias_for_alias')); + } + public function testOverrideServiceWhenUsingADumpedContainer() { require_once self::$fixturesPath.'/php/services9.php'; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php index 71d29f209bfc..6abe5e2a917f 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php @@ -43,6 +43,7 @@ 'foo' => 'bar', )); $container->setAlias('alias_for_foo', 'foo'); +$container->setAlias('alias_for_alias', 'alias_for_foo'); $container-> register('method_call1', 'FooClass')-> setFile(realpath(__DIR__.'/../includes/foo.php'))-> @@ -71,5 +72,14 @@ ->register('baz', 'Baz') ->addMethodCall('setFoo', array(new Reference('foo_with_inline'))) ; +$container + ->register('request', 'Request') + ->setSynthetic(true) + ->setSynchronized(true) +; +$container + ->register('depends_on_request', 'stdClass') + ->addMethodCall('setRequest', array(new Reference('request', ContainerInterface::NULL_ON_INVALID_REFERENCE, false))) +; return $container; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot index 73608e27fc91..cb006641d0b1 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot @@ -12,6 +12,8 @@ digraph sc { node_foo_with_inline [label="foo_with_inline\nFoo\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_inlined [label="inlined\nBar\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_baz [label="baz\nBaz\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_request [label="request\nRequest\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_depends_on_request [label="depends_on_request\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"]; node_foo2 [label="foo2\n\n", shape=record, fillcolor="#ff9999", style="filled"]; node_foo3 [label="foo3\n\n", shape=record, fillcolor="#ff9999", style="filled"]; @@ -28,4 +30,5 @@ digraph sc { node_foo_with_inline -> node_inlined [label="setBar()" style="dashed"]; node_inlined -> node_baz [label="setBaz()" style="dashed"]; node_baz -> node_foo_with_inline [label="setFoo()" style="dashed"]; + node_depends_on_request -> node_request [label="setRequest()" style="dashed"]; } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php index fb6d4cf19d5c..48e1c2c84e12 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php @@ -13,6 +13,11 @@ public function setBaz(BazClass $baz) { $this->baz = $baz; } + + public function getBaz() + { + return $this->baz; + } } class BazClass diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/createphar.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/createphar.php index a5933513da5e..1640020d93e9 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/createphar.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/createphar.php @@ -1,6 +1,6 @@ <?php -$file = __DIR__ . '/ProjectWithXsdExtensionInPhar.phar'; +$file = __DIR__.'/ProjectWithXsdExtensionInPhar.phar'; if (is_file($file)) { @unlink($file); } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index 5f321e33a4a5..15c16709d325 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -33,6 +33,9 @@ public function __construct() $this->scopes = array(); $this->scopeChildren = array(); + $this->methodMap = array( + 'test' => 'getTestService', + ); } /** diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php index 80d24c540dbd..9361a0e87c5a 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php @@ -24,6 +24,23 @@ class ProjectServiceContainer extends Container public function __construct() { parent::__construct(new ParameterBag($this->getDefaultParameters())); + $this->methodMap = array( + 'bar' => 'getBarService', + 'baz' => 'getBazService', + 'depends_on_request' => 'getDependsOnRequestService', + 'factory_service' => 'getFactoryServiceService', + 'foo' => 'getFooService', + 'foo.baz' => 'getFoo_BazService', + 'foo_bar' => 'getFooBarService', + 'foo_with_inline' => 'getFooWithInlineService', + 'inlined' => 'getInlinedService', + 'method_call1' => 'getMethodCall1Service', + 'request' => 'getRequestService', + ); + $this->aliases = array( + 'alias_for_alias' => 'foo', + 'alias_for_foo' => 'foo', + ); } /** @@ -60,6 +77,23 @@ protected function getBazService() return $instance; } + /** + * Gets the 'depends_on_request' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return stdClass A stdClass instance. + */ + protected function getDependsOnRequestService() + { + $this->services['depends_on_request'] = $instance = new \stdClass(); + + $instance->setRequest($this->get('request', ContainerInterface::NULL_ON_INVALID_REFERENCE)); + + return $instance; + } + /** * Gets the 'factory_service' service. * @@ -102,7 +136,7 @@ protected function getFooService() * This service is shared. * This method always returns the same instance of the service. * - * @return Object A %baz_class% instance. + * @return object A %baz_class% instance. */ protected function getFoo_BazService() { @@ -116,7 +150,7 @@ protected function getFoo_BazService() /** * Gets the 'foo_bar' service. * - * @return Object A %foo_class% instance. + * @return object A %foo_class% instance. */ protected function getFooBarService() { @@ -169,13 +203,26 @@ protected function getMethodCall1Service() } /** - * Gets the alias_for_foo service alias. + * Gets the 'request' service. + * + * This service is shared. + * This method always returns the same instance of the service. * - * @return FooClass An instance of the foo service + * @throws RuntimeException always since this service is expected to be injected dynamically */ - protected function getAliasForFooService() + protected function getRequestService() { - return $this->get('foo'); + throw new RuntimeException('You have requested a synthetic service ("request"). The DIC does not know how to construct this service.'); + } + + /** + * Updates the 'request' service. + */ + protected function synchronizeRequestService() + { + if ($this->initialized('depends_on_request')) { + $this->get('depends_on_request')->setRequest($this->get('request', ContainerInterface::NULL_ON_INVALID_REFERENCE)); + } } /** diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index 5c71db9e66ab..b60cbff8e8bb 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -33,6 +33,22 @@ public function __construct() $this->scopes = array(); $this->scopeChildren = array(); + $this->methodMap = array( + 'bar' => 'getBarService', + 'baz' => 'getBazService', + 'depends_on_request' => 'getDependsOnRequestService', + 'factory_service' => 'getFactoryServiceService', + 'foo' => 'getFooService', + 'foo.baz' => 'getFoo_BazService', + 'foo_bar' => 'getFooBarService', + 'foo_with_inline' => 'getFooWithInlineService', + 'method_call1' => 'getMethodCall1Service', + 'request' => 'getRequestService', + ); + $this->aliases = array( + 'alias_for_alias' => 'foo', + 'alias_for_foo' => 'foo', + ); } /** @@ -69,6 +85,23 @@ protected function getBazService() return $instance; } + /** + * Gets the 'depends_on_request' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return stdClass A stdClass instance. + */ + protected function getDependsOnRequestService() + { + $this->services['depends_on_request'] = $instance = new \stdClass(); + + $instance->setRequest($this->get('request', ContainerInterface::NULL_ON_INVALID_REFERENCE)); + + return $instance; + } + /** * Gets the 'factory_service' service. * @@ -175,13 +208,26 @@ protected function getMethodCall1Service() } /** - * Gets the alias_for_foo service alias. + * Gets the 'request' service. + * + * This service is shared. + * This method always returns the same instance of the service. * - * @return FooClass An instance of the foo service + * @throws RuntimeException always since this service is expected to be injected dynamically */ - protected function getAliasForFooService() + protected function getRequestService() { - return $this->get('foo'); + throw new RuntimeException('You have requested a synthetic service ("request"). The DIC does not know how to construct this service.'); + } + + /** + * Updates the 'request' service. + */ + protected function synchronizeRequestService() + { + if ($this->initialized('depends_on_request')) { + $this->get('depends_on_request')->setRequest($this->get('request', ContainerInterface::NULL_ON_INVALID_REFERENCE)); + } } /** diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml index bada1c892fb0..6e8a6ce364dc 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml @@ -16,7 +16,7 @@ <parameter>on</parameter> <parameter>off</parameter> <parameter key="float">1.3</parameter> - <parameter>1,000.3</parameter> + <parameter>1000.3</parameter> <parameter>a string</parameter> <parameter type="collection"> <parameter>foo</parameter> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml index 45bc042f6190..abd9fbc1529b 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml @@ -46,5 +46,6 @@ <service id="alias_for_foo" alias="foo" /> <service id="another_alias_for_foo" alias="foo" public="false" /> <service id="factory_service" factory-method="getInstance" factory-service="baz_factory" /> + <service id="request" class="Request" synthetic="true" synchronized="true" lazy="true"/> </services> </container> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml index 58eb6d79a3c1..cb3a1f69ded5 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml @@ -67,6 +67,13 @@ <argument type="service" id="foo_with_inline"/> </call> </service> + <service id="request" class="Request" synthetic="true" synchronized="true"/> + <service id="depends_on_request" class="stdClass"> + <call method="setRequest"> + <argument type="service" id="request" on-invalid="null" strict="false"/> + </call> + </service> <service id="alias_for_foo" alias="foo"/> + <service id="alias_for_alias" alias="foo"/> </services> </container> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml index eaa52bda6206..7ba9453bdd6d 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml @@ -24,3 +24,8 @@ services: alias: foo public: false factory_service: { class: BazClass, factory_method: getInstance, factory_service: baz_factory } + request: + class: Request + synthetic: true + synchronized: true + lazy: true diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml index fcbb83f4ae7e..6a4c3d5d97a0 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml @@ -9,6 +9,7 @@ services: tags: - { name: foo, foo: foo } - { name: foo, bar: bar } + factory_class: FooClass factory_method: getInstance arguments: [foo, '@foo.baz', { '%foo%': 'foo is %foo%', foobar: '%foo%' }, true, '@service_container'] properties: { foo: bar, moo: '@foo.baz' } @@ -23,6 +24,7 @@ services: configurator: ['@foo.baz', configure] foo.baz: class: %baz_class% + factory_class: %baz_class% factory_method: getInstance configurator: ['%baz_class%', configureStatic1] foo_bar: @@ -57,4 +59,14 @@ services: calls: - [setFoo, ['@foo_with_inline']] + request: + class: Request + synthetic: true + synchronized: true + depends_on_request: + class: stdClass + calls: + - [setRequest, ['@?request']] + alias_for_foo: @foo + alias_for_alias: @foo diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php new file mode 100644 index 000000000000..5fb202696492 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php @@ -0,0 +1,37 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\LazyProxy\Instantiator; + +use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\RealServiceInstantiator; + +/** + * Tests for {@see \Symfony\Component\DependencyInjection\Instantiator\RealServiceInstantiator} + * + * @author Marco Pivetta <ocramius@gmail.com> + * + * @covers \Symfony\Component\DependencyInjection\LazyProxy\Instantiator\RealServiceInstantiator + */ +class RealServiceInstantiatorTest extends \PHPUnit_Framework_TestCase +{ + public function testInstantiateProxy() + { + $instantiator = new RealServiceInstantiator(); + $instance = new \stdClass(); + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $callback = function () use ($instance) { + return $instance; + }; + + $this->assertSame($instance, $instantiator->instantiateProxy($container, new Definition(), 'foo', $callback)); + } +} diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/LazyProxy/PhpDumper/NullDumperTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/LazyProxy/PhpDumper/NullDumperTest.php new file mode 100644 index 000000000000..646673662a61 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/LazyProxy/PhpDumper/NullDumperTest.php @@ -0,0 +1,35 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\LazyProxy\PhpDumper; + +use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper; + +/** + * Tests for {@see \Symfony\Component\DependencyInjection\PhpDumper\NullDumper} + * + * @author Marco Pivetta <ocramius@gmail.com> + * + * @covers \Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper + */ +class NullDumperTest extends \PHPUnit_Framework_TestCase +{ + public function testNullDumper() + { + $dumper = new NullDumper(); + $definition = new Definition('stdClass'); + + $this->assertFalse($dumper->isProxyCandidate($definition)); + $this->assertSame('', $dumper->getProxyFactoryCode($definition, 'foo')); + $this->assertSame('', $dumper->getProxyCode($definition)); + } +} diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index 0287a1b0aa33..d8138f947541 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -185,6 +185,10 @@ public function testLoadServices() $this->assertEquals('getInstance', $services['factory_service']->getFactoryMethod()); $this->assertEquals('baz_factory', $services['factory_service']->getFactoryService()); + $this->assertTrue($services['request']->isSynthetic(), '->load() parses the synthetic flag'); + $this->assertTrue($services['request']->isSynchronized(), '->load() parses the synchronized flag'); + $this->assertTrue($services['request']->isLazy(), '->load() parses the lazy flag'); + $aliases = $container->getAliases(); $this->assertTrue(isset($aliases['alias_for_foo']), '->load() parses <service> elements'); $this->assertEquals('foo', (string) $aliases['alias_for_foo'], '->load() parses aliases'); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 39cfce52f3d6..e452e5d221d1 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -128,6 +128,10 @@ public function testLoadServices() $this->assertEquals(array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), $services['method_call2']->getMethodCalls(), '->load() parses the method_call tag'); $this->assertEquals('baz_factory', $services['factory_service']->getFactoryService()); + $this->assertTrue($services['request']->isSynthetic(), '->load() parses the synthetic flag'); + $this->assertTrue($services['request']->isSynchronized(), '->load() parses the synchronized flag'); + $this->assertTrue($services['request']->isLazy(), '->load() parses the lazy flag'); + $aliases = $container->getAliases(); $this->assertTrue(isset($aliases['alias_for_foo']), '->load() parses aliases'); $this->assertEquals('foo', (string) $aliases['alias_for_foo'], '->load() parses aliases'); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php index 968ae9bcf5f4..e1f8169f8851 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php @@ -77,10 +77,43 @@ public function testGetSet() try { $bag->get('baba'); - $this->fail('->get() throws an \InvalidArgumentException if the key does not exist'); + $this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->get() throws an \InvalidArgumentException if the key does not exist'); - $this->assertEquals('You have requested a non-existent parameter "baba".', $e->getMessage(), '->get() throws an \InvalidArgumentException if the key does not exist'); + $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); + $this->assertEquals('You have requested a non-existent parameter "baba".', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); + } + } + + public function testGetThrowParameterNotFoundException() + { + $bag = new ParameterBag(array( + 'foo' => 'foo', + 'bar' => 'bar', + 'baz' => 'baz', + )); + + try { + $bag->get('foo1'); + $this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); + $this->assertEquals('You have requested a non-existent parameter "foo1". Did you mean this: "foo"?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException with some advices'); + } + + try { + $bag->get('bag'); + $this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); + $this->assertEquals('You have requested a non-existent parameter "bag". Did you mean one of these: "bar", "baz"?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException with some advices'); + } + + try { + $bag->get(''); + $this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); + $this->assertEquals('You have requested a non-existent parameter "".', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException with some advices'); } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/composer.json b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/composer.json index 33357d3af176..2631da96df2f 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/composer.json +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/composer.json @@ -20,11 +20,12 @@ }, "require-dev": { "symfony/yaml": "~2.0", - "symfony/config": ">=2.2,<2.3-dev" + "symfony/config": "~2.2" }, "suggest": { - "symfony/yaml": "2.2.*", - "symfony/config": "2.2.*" + "symfony/yaml": "", + "symfony/config": "", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them" }, "autoload": { "psr-0": { "Symfony\\Component\\DependencyInjection\\": "" } @@ -33,7 +34,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json index efc320c95e92..1db2ecfd6c87 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json @@ -22,8 +22,8 @@ "symfony/dependency-injection": "~2.0" }, "suggest": { - "symfony/dependency-injection": "2.2.*", - "symfony/http-kernel": "2.2.*" + "symfony/dependency-injection": "", + "symfony/http-kernel": "" }, "autoload": { "psr-0": { "Symfony\\Component\\EventDispatcher\\": "" } @@ -32,7 +32,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ApacheRequest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ApacheRequest.php index ca8f8eebbf88..84803ebae28f 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ApacheRequest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ApacheRequest.php @@ -40,12 +40,4 @@ protected function prepareBaseUrl() return $baseUrl; } - - /** - * {@inheritdoc} - */ - protected function preparePathInfo() - { - return $this->server->get('PATH_INFO') ?: substr($this->prepareRequestUri(), strlen($this->prepareBaseUrl())) ?: '/'; - } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php index cb6c8a1e8ad0..06d530ddf833 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -166,6 +166,8 @@ public function prepare(Request $request) $this->setProtocolVersion('1.1'); } + $this->ensureIEOverSSLCompatibility($request); + $this->offset = 0; $this->maxlen = -1; @@ -183,7 +185,7 @@ public function prepare(Request $request) $pathPrefix = trim($mapping[1]); if (substr($path, 0, strlen($pathPrefix)) == $pathPrefix) { - $path = $location . substr($path, strlen($pathPrefix)); + $path = $location.substr($path, strlen($pathPrefix)); break; } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md index 318383aa565f..41e8eb2ec32a 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md @@ -1,6 +1,15 @@ CHANGELOG ========= +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 ----- diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php index fdc33e3679e3..68fe853b2f08 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php @@ -93,11 +93,11 @@ public function __toString() } } - if ('/' !== $this->path) { + if ($this->path) { $str .= '; path='.$this->path; } - if (null !== $this->getDomain()) { + if ($this->getDomain()) { $str .= '; domain='.$this->getDomain(); } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php index 729d870cfc5f..9002b510851a 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php @@ -49,9 +49,15 @@ public function __construct($path, $checkPath = true) * * 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() { @@ -64,12 +70,14 @@ public function guessExtension() /** * Returns the mime type of the file. * - * The mime type is guessed using the functions finfo(), mime_content_type() - * and the system binary "file" (in this order), depending on which of those - * is available on the current operating system. + * 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() diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php index d5715f6f5506..cc646180c888 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php @@ -16,15 +16,12 @@ * * A default guesser is provided. * You can register custom guessers by calling the register() - * method on the singleton instance. + * method on the singleton instance: * - * <code> - * $guesser = ExtensionGuesser::getInstance(); - * $guesser->register(new MyCustomExtensionGuesser()); - * </code> + * $guesser = ExtensionGuesser::getInstance(); + * $guesser->register(new MyCustomExtensionGuesser()); * * The last registered guesser is preferred over previously registered ones. - * */ class ExtensionGuesser implements ExtensionGuesserInterface { diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php index 09a0d7ed198f..a6950df2cd6c 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php @@ -15,12 +15,26 @@ use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; /** - * Guesses the mime type using the PECL extension FileInfo + * Guesses the mime type using the PECL extension FileInfo. * * @author Bernhard Schussek <bschussek@gmail.com> */ 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 * @@ -48,7 +62,7 @@ public function guess($path) return null; } - if (!$finfo = new \finfo(FILEINFO_MIME_TYPE)) { + if (!$finfo = new \finfo(FILEINFO_MIME_TYPE, $this->magicFile)) { return null; } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php index 13fe4a2fdc8d..42e7b77af0a1 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php @@ -20,6 +20,7 @@ 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 * @@ -39,6 +40,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -46,6 +48,9 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -54,6 +59,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -64,6 +70,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -75,6 +82,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -122,6 +130,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -136,6 +145,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -178,6 +188,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -188,6 +199,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -248,7 +260,6 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface 'application/vnd.hp-pcl' => 'pcl', 'application/vnd.hp-pclxl' => 'pclxl', 'application/vnd.hydrostatix.sof-data' => 'sfd-hdstx', - 'application/vnd.hzn-3d-crossword' => 'x3d', 'application/vnd.ibm.minipay' => 'mpy', 'application/vnd.ibm.modcap' => 'afp', 'application/vnd.ibm.rights-management' => 'irm', @@ -344,6 +355,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -384,6 +396,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -403,6 +416,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -486,25 +500,33 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -514,14 +536,23 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -538,35 +569,47 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -579,6 +622,8 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -593,12 +638,16 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -614,6 +663,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -628,14 +678,17 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -643,6 +696,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -656,6 +710,10 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -688,7 +746,10 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', @@ -720,13 +781,17 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface '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', ); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php index 59ddc077be0a..f6bf2cd39df7 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php @@ -18,15 +18,22 @@ * 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. + * (if available on the current OS/PHP setup). * - * <code> - * $guesser = MimeTypeGuesser::getInstance(); - * $guesser->register(new MyCustomMimeTypeGuesser()); - * </code> + * You can register custom guessers by calling the register() method on the + * singleton instance. Custom guessers are always called before any default ones. * - * The last registered guesser is preferred over previously registered 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 <bschussek@gmail.com> */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php index 63c5386a11b9..1f23c35c6b8b 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -13,6 +13,7 @@ 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. @@ -134,11 +135,16 @@ public function getClientOriginalExtension() /** * Returns the file mime type. * - * It is extracted from the request from which the file has been uploaded. - * Then is should not be considered as a safe value. + * 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() @@ -146,6 +152,31 @@ 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. * @@ -179,13 +210,15 @@ public function getError() /** * Returns whether the file was uploaded successfully. * - * @return Boolean True if no error occurred during uploading + * @return Boolean True if the file has been uploaded with HTTP and no error occurred. * * @api */ public function isValid() { - return $this->error === UPLOAD_ERR_OK; + $isOk = $this->error === UPLOAD_ERR_OK; + + return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname()); } /** @@ -196,7 +229,7 @@ public function isValid() * * @return File A File object representing the new file * - * @throws FileException if the file has not been uploaded via Http + * @throws FileException if, for any reason, the file could not have been moved * * @api */ @@ -205,21 +238,21 @@ public function move($directory, $name = null) if ($this->isValid()) { if ($this->test) { return parent::move($directory, $name); - } elseif (is_uploaded_file($this->getPathname())) { - $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()); + $target = $this->getTargetFile($directory, $name); - return $target; + 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(sprintf('The file "%s" has not been uploaded via Http', $this->getPathname())); + throw new FileException($this->getErrorMessage($this->getError())); } /** @@ -229,21 +262,44 @@ public function move($directory, $name = null) */ public static function getMaxFilesize() { - $max = trim(ini_get('upload_max_filesize')); + $max = strtolower(ini_get('upload_max_filesize')); if ('' === $max) { return PHP_INT_MAX; } - switch (strtolower(substr($max, -1))) { - case 'g': - $max *= 1024; - case 'm': - $max *= 1024; - case 'k': - $max *= 1024; + if (preg_match('#^\+?(0x?)?(.*?)([kmg]?)$#', $max, $match)) { + $shifts = array('' => 0, 'k' => 10, 'm' => 20, 'g' => 30); + $bases = array('' => 10, '0' => 8, '0x' => 16); + + return intval($match[2], $bases[$match[1]]) << $shifts[$match[3]]; } - return (integer) $max; + return 0; + } + + /** + * Returns an informative upload error message. + * + * @param int $code The error code returned by an upload attempt + * + * @return string The error message regarding the specified error code + */ + private function getErrorMessage($errorCode) + { + static $errors = array( + UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d kb).', + 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.', + ); + + $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/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php index 2e3e1aa74635..7c3742e768f9 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php @@ -26,18 +26,26 @@ private function __construct() {} /** * Validates an IPv4 or IPv6 address. * - * @param string $requestIp - * @param string $ip + * @param string $requestIp + * @param string|array $ips * * @return boolean Whether the IP is valid */ - public static function checkIp($requestIp, $ip) + public static function checkIp($requestIp, $ips) { - if (false !== strpos($requestIp, ':')) { - return self::checkIp6($requestIp, $ip); + if (!is_array($ips)) { + $ips = array($ips); + } + + $method = false !== strpos($requestIp, ':') ? 'checkIp6': 'checkIp4'; + + foreach ($ips as $ip) { + if (self::$method($requestIp, $ip)) { + return true; + } } - return self::checkIp4($requestIp, $ip); + return false; } /** diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php index b6ac8017a3cd..eafccaa844dc 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php @@ -14,6 +14,12 @@ /** * 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 <igor@wiedler.ch> */ class JsonResponse extends Response diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php index c48082a675f3..756e4847d8d4 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php @@ -35,8 +35,6 @@ class Request const HEADER_CLIENT_PROTO = 'client_proto'; const HEADER_CLIENT_PORT = 'client_port'; - protected static $trustProxy = false; - protected static $trustedProxies = array(); /** @@ -464,18 +462,6 @@ public function overrideGlobals() } } - /** - * Trusts $_SERVER entries coming from proxies. - * - * @deprecated Deprecated since version 2.0, to be removed in 2.3. Use setTrustedProxies instead. - */ - public static function trustProxyData() - { - trigger_error('trustProxyData() is deprecated since version 2.0 and will be removed in 2.3. Use setTrustedProxies() instead.', E_USER_DEPRECATED); - - self::$trustProxy = true; - } - /** * Sets a list of trusted proxies. * @@ -488,7 +474,6 @@ public static function trustProxyData() public static function setTrustedProxies(array $proxies) { self::$trustedProxies = $proxies; - self::$trustProxy = $proxies ? true : false; } /** @@ -528,16 +513,21 @@ public static function setTrustedHeaderName($key, $value) } /** - * Returns true if $_SERVER entries coming from proxies are trusted, - * false otherwise. + * Gets the trusted proxy header name. + * + * @param string $key The header key * - * @return boolean + * @return string The header name * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. Use getTrustedProxies instead. + * @throws \InvalidArgumentException */ - public static function isProxyTrusted() + public static function getTrustedHeaderName($key) { - return self::$trustProxy; + 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]; } /** @@ -686,6 +676,48 @@ public function setSession(SessionInterface $session) $this->session = $session; } + /** + * Returns the client IP addresses. + * + * The most trusted IP address is first, and the less trusted one last. + * The "real" client IP address is the last one, but this is also the + * less trusted one. + * + * 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 (!self::$trustedProxies) { + 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; + + $trustedProxies = !self::$trustedProxies ? array($ip) : self::$trustedProxies; + $ip = $clientIps[0]; + + foreach ($clientIps as $key => $clientIp) { + if (IpUtils::checkIp($clientIp, $trustedProxies)) { + unset($clientIps[$key]); + + continue; + } + } + + return $clientIps ? array_reverse($clientIps) : array($ip); + } + /** * Returns the client IP address. * @@ -701,29 +733,16 @@ public function setSession(SessionInterface $session) * * @return string The client IP address * + * @see getClientIps() * @see http://en.wikipedia.org/wiki/X-Forwarded-For * * @api */ public function getClientIp() { - $ip = $this->server->get('REMOTE_ADDR'); - - if (!self::$trustProxy) { - return $ip; - } + $ipAddresses = $this->getClientIps(); - if (!self::$trustedHeaders[self::HEADER_CLIENT_IP] || !$this->headers->has(self::$trustedHeaders[self::HEADER_CLIENT_IP])) { - return $ip; - } - - $clientIps = array_map('trim', explode(',', $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_IP]))); - $clientIps[] = $ip; - - $trustedProxies = self::$trustProxy && !self::$trustedProxies ? array($ip) : self::$trustedProxies; - $clientIps = array_diff($clientIps, $trustedProxies); - - return array_pop($clientIps); + return $ipAddresses[0]; } /** @@ -836,8 +855,14 @@ public function getScheme() */ public function getPort() { - if (self::$trustProxy && self::$trustedHeaders[self::HEADER_CLIENT_PORT] && $port = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PORT])) { - return $port; + if (self::$trustedProxies) { + 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; + } } return $this->server->get('SERVER_PORT'); @@ -997,7 +1022,7 @@ public function getQueryString() */ public function isSecure() { - if (self::$trustProxy && self::$trustedHeaders[self::HEADER_CLIENT_PROTO] && $proto = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PROTO])) { + if (self::$trustedProxies && self::$trustedHeaders[self::HEADER_CLIENT_PROTO] && $proto = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PROTO])) { return in_array(strtolower($proto), array('https', 'on', '1')); } @@ -1023,7 +1048,7 @@ public function isSecure() */ public function getHost() { - if (self::$trustProxy && self::$trustedHeaders[self::HEADER_CLIENT_HOST] && $host = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_HOST])) { + if (self::$trustedProxies && self::$trustedHeaders[self::HEADER_CLIENT_HOST] && $host = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_HOST])) { $elements = explode(',', $host); $host = $elements[count($elements) - 1]; @@ -1451,31 +1476,6 @@ public function isXmlHttpRequest() return 'XMLHttpRequest' == $this->headers->get('X-Requested-With'); } - /** - * Splits an Accept-* HTTP header. - * - * @param string $header Header to split - * - * @return array Array indexed by the values of the Accept-* header in preferred order - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. - */ - public function splitHttpAcceptHeader($header) - { - trigger_error('splitHttpAcceptHeader() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); - - $headers = array(); - foreach (AcceptHeader::fromString($header)->all() as $item) { - $key = $item->getValue(); - foreach ($item->getAttributes() as $name => $value) { - $key .= sprintf(';%s=%s', $name, $value); - } - $headers[$key] = $item->getQuality(); - } - - return $headers; - } - /* * The following methods are derived from code of the Zend Framework (1.10dev - 2010-01-24) * @@ -1488,11 +1488,14 @@ protected function prepareRequestUri() { $requestUri = ''; - if ($this->headers->has('X_ORIGINAL_URL') && false !== stripos(PHP_OS, 'WIN')) { + 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'); - } elseif ($this->headers->has('X_REWRITE_URL') && false !== stripos(PHP_OS, 'WIN')) { + $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'); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php index 49b92f0e2cbb..769ca66ecd48 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php @@ -38,7 +38,7 @@ class RequestMatcher implements RequestMatcherInterface /** * @var string */ - private $ip; + private $ips = array(); /** * @var array @@ -49,15 +49,15 @@ class RequestMatcher implements RequestMatcherInterface * @param string|null $path * @param string|null $host * @param string|string[]|null $methods - * @param string|null $ip + * @param string|string[]|null $ips * @param array $attributes */ - public function __construct($path = null, $host = null, $methods = null, $ip = null, array $attributes = array()) + public function __construct($path = null, $host = null, $methods = null, $ips = null, array $attributes = array()) { $this->matchPath($path); $this->matchHost($host); $this->matchMethod($methods); - $this->matchIp($ip); + $this->matchIps($ips); foreach ($attributes as $k => $v) { $this->matchAttribute($k, $v); } @@ -90,7 +90,17 @@ public function matchPath($regexp) */ public function matchIp($ip) { - $this->ip = $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; } /** @@ -126,27 +136,26 @@ public function matches(Request $request) } foreach ($this->attributes as $key => $pattern) { - if (!preg_match('#'.str_replace('#', '\\#', $pattern).'#', $request->attributes->get($key))) { + if (!preg_match('{'.$pattern.'}', $request->attributes->get($key))) { return false; } } - if (null !== $this->path) { - $path = str_replace('#', '\\#', $this->path); - - if (!preg_match('#'.$path.'#', rawurldecode($request->getPathInfo()))) { - return false; - } + if (null !== $this->path && !preg_match('{'.$this->path.'}', rawurldecode($request->getPathInfo()))) { + return false; } - if (null !== $this->host && !preg_match('#'.str_replace('#', '\\#', $this->host).'#i', $request->getHost())) { + if (null !== $this->host && !preg_match('{'.$this->host.'}i', $request->getHost())) { return false; } - if (null !== $this->ip && !IpUtils::checkIp($request->getClientIp(), $this->ip)) { - return false; + if (IpUtils::checkIp($request->getClientIp(), $this->ips)) { + return true; } - 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/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php index 7ac4e8005603..c4c5a53da6df 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php @@ -253,15 +253,7 @@ public function prepare(Request $request) $this->headers->set('expires', -1); } - /** - * Check if we need to remove Cache-Control for ssl encrypted downloads when using IE < 9 - * @link http://support.microsoft.com/kb/323308 - */ - 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 (intval(preg_replace("/(MSIE )(.*?);/", "$2", $match[0])) < 9) { - $this->headers->remove('Cache-Control'); - } - } + $this->ensureIEOverSSLCompatibility($request); return $this; } @@ -355,7 +347,7 @@ public function send() public function setContent($content) { if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable(array($content, '__toString'))) { - throw new \UnexpectedValueException('The Response content must be a string or object implementing __toString(), "'.gettype($content).'" given.'); + throw new \UnexpectedValueException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', gettype($content))); } $this->content = (string) $content; @@ -692,7 +684,7 @@ public function setExpires(\DateTime $date = null) /** * Returns the number of seconds after the time specified in the response's Date - * header when the the response should no longer be considered fresh. + * 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. @@ -1179,4 +1171,18 @@ public function isEmpty() { return in_array($this->statusCode, array(201, 204, 304)); } + + /** + * Check 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 (intval(preg_replace("/(MSIE )(.*?);/", "$2", $match[0])) < 9) { + $this->headers->remove('Cache-Control'); + } + } + } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php index fcb41cc5ee0a..d7aadc6bb65f 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php @@ -28,12 +28,13 @@ class ServerBag extends ParameterBag 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 (in_array($key, array('CONTENT_LENGTH', 'CONTENT_MD5', 'CONTENT_TYPE'))) { + elseif (isset($contentHeaders[$key])) { $headers[$key] = $value; } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php index 138aa3614598..25dcd228694c 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php @@ -46,6 +46,10 @@ public function has($name) $attributes = $this->resolveAttributePath($name); $name = $this->resolveKey($name); + if (null === $attributes) { + return false; + } + return array_key_exists($name, $attributes); } @@ -57,6 +61,10 @@ public function get($name, $default = null) $attributes = $this->resolveAttributePath($name); $name = $this->resolveKey($name); + if (null === $attributes) { + return $default; + } + return array_key_exists($name, $attributes) ? $attributes[$name] : $default; } @@ -120,12 +128,8 @@ protected function &resolveAttributePath($name, $writeContext = false) unset($parts[count($parts)-1]); foreach ($parts as $part) { - if (!array_key_exists($part, $array)) { - if (!$writeContext) { - return $array; - } - - $array[$part] = array(); + if (null !== $array && !array_key_exists($part, $array)) { + $array[$part] = $writeContext ? array() : null; } $array = & $array[$part]; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php index 5bb43bc53a4b..d62e3835abe0 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php @@ -16,7 +16,7 @@ * * @author Drak <drak@zikula.org> */ -class FlashBag implements FlashBagInterface, \IteratorAggregate, \Countable +class FlashBag implements FlashBagInterface, \IteratorAggregate { private $name = 'flashes'; @@ -173,21 +173,4 @@ public function getIterator() { return new \ArrayIterator($this->all()); } - - /** - * Returns the number of flashes. - * - * This method does not work. - * - * @deprecated in 2.2, removed in 2.3 - * @see https://github.com/symfony/symfony/issues/6408 - * - * @return int The number of flashes - */ - public function count() - { - trigger_error(sprintf('%s() is deprecated since 2.2 and will be removed in 2.3', __METHOD__), E_USER_DEPRECATED); - - return count($this->flashes); - } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php index b0b3ff3d0bff..15df09770994 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php @@ -249,113 +249,4 @@ public function getFlashBag() { return $this->getBag($this->flashName); } - - // the following methods are kept for compatibility with Symfony 2.0 (they will be removed for Symfony 2.3) - - /** - * @return array - * - * @deprecated since 2.1, will be removed from 2.3 - */ - public function getFlashes() - { - trigger_error('getFlashes() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED); - - $all = $this->getBag($this->flashName)->all(); - - $return = array(); - if ($all) { - foreach ($all as $name => $array) { - if (is_numeric(key($array))) { - $return[$name] = reset($array); - } else { - $return[$name] = $array; - } - } - } - - return $return; - } - - /** - * @param array $values - * - * @deprecated since 2.1, will be removed from 2.3 - */ - public function setFlashes($values) - { - trigger_error('setFlashes() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED); - - foreach ($values as $name => $value) { - $this->getBag($this->flashName)->set($name, $value); - } - } - - /** - * @param string $name - * @param string $default - * - * @return string - * - * @deprecated since 2.1, will be removed from 2.3 - */ - public function getFlash($name, $default = null) - { - trigger_error('getFlash() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED); - - $return = $this->getBag($this->flashName)->get($name); - - return empty($return) ? $default : reset($return); - } - - /** - * @param string $name - * @param string $value - * - * @deprecated since 2.1, will be removed from 2.3 - */ - public function setFlash($name, $value) - { - trigger_error('setFlash() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED); - - $this->getBag($this->flashName)->set($name, $value); - } - - /** - * @param string $name - * - * @return Boolean - * - * @deprecated since 2.1, will be removed from 2.3 - */ - public function hasFlash($name) - { - trigger_error('hasFlash() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED); - - return $this->getBag($this->flashName)->has($name); - } - - /** - * @param string $name - * - * @deprecated since 2.1, will be removed from 2.3 - */ - public function removeFlash($name) - { - trigger_error('removeFlash() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED); - - $this->getBag($this->flashName)->get($name); - } - - /** - * @return array - * - * @deprecated since 2.1, will be removed from 2.3 - */ - public function clearFlashes() - { - trigger_error('clearFlashes() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED); - - return $this->getBag($this->flashName)->clear(); - } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index 487dbc41e50e..347cbee706a0 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -48,7 +48,9 @@ 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; $this->dbOptions = array_merge(array( 'db_id_col' => 'sess_id', diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index 4b9be5e9b291..36d87a707e3f 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -12,6 +12,7 @@ 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\MetadataBag; use Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy; use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; @@ -91,13 +92,13 @@ class NativeSessionStorage implements SessionStorageInterface * upload_progress.min-freq, "1" * url_rewriter.tags, "a=href,area=href,frame=src,form=,fieldset=" * - * @param array $options Session configuration options. - * @param object $handler SessionHandlerInterface. - * @param MetadataBag $metaBag MetadataBag. + * @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) { - ini_set('session.cache_limiter', ''); // disable by default because it's managed by HeaderBag (if used) + session_cache_limiter(''); // disable by default because it's managed by HeaderBag (if used) ini_set('session.use_cookies', 1); if (version_compare(phpversion(), '5.4.0', '>=')) { @@ -130,27 +131,28 @@ public function start() return true; } - // catch condition where session was started automatically by PHP - if (!$this->started && !$this->closed && $this->saveHandler->isActive() - && $this->saveHandler->isSessionHandlerInterface()) { - $this->loadSession(); + if (version_compare(phpversion(), '5.4.0', '>=') && \PHP_SESSION_ACTIVE === session_status()) { + throw new \RuntimeException('Failed to start the session: already started by PHP.'); + } - return true; + if (version_compare(phpversion(), '5.4.0', '<') && 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()) { - throw new \RuntimeException('Failed to start the session because headers have already been sent.'); + 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)); } - // start the session + // 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->saveHandler->setActive(false); + // This condition matches only PHP 5.3 with internal save handlers + $this->saveHandler->setActive(true); } return true; @@ -215,7 +217,8 @@ public function save() { session_write_close(); - if (!$this->saveHandler->isWrapper() && !$this->getSaveHandler()->isSessionHandlerInterface()) { + if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) { + // This condition matches only PHP 5.3 with internal save handlers $this->saveHandler->setActive(false); } @@ -329,7 +332,7 @@ public function setOptions(array $options) } /** - * Registers save handler as a PHP session handler. + * 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. @@ -337,21 +340,35 @@ public function setOptions(array $options) * 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 * - * @param object $saveHandler Default null means NativeProxy. + * @throws \InvalidArgumentException */ public function setSaveHandler($saveHandler = null) { - // Wrap $saveHandler in proxy + 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 = new NativeProxy(); + $saveHandler = version_compare(phpversion(), '5.4.0', '>=') ? + new SessionHandlerProxy(new \SessionHandler()) : new NativeProxy(); } - $this->saveHandler = $saveHandler; if ($this->saveHandler instanceof \SessionHandlerInterface) { diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php new file mode 100644 index 000000000000..0f0020397ad5 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php @@ -0,0 +1,69 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Session\Storage; + +use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; +use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; +use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler; + +/** + * Allows session to be started by PHP and managed by Symfony2 + * + * @author Drak <drak@zikula.org> + */ +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 && !$this->closed) { + 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/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php index 1f68f2496133..ee6eb897287c 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php @@ -72,16 +72,31 @@ public function isWrapper() */ public function isActive() { + if (version_compare(phpversion(), '5.4.0', '>=')) { + 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 Boolean $flag + * + * @throws \LogicException */ public function setActive($flag) { + if (version_compare(phpversion(), '5.4.0', '>=')) { + throw new \LogicException('This method is disabled in PHP 5.4.0+'); + } + $this->active = (bool) $flag; } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index 4d517313f392..c3d324fa9f07 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\ResponseHeaderBag; -class BinaryFileResponseTest extends \PHPUnit_Framework_TestCase +class BinaryFileResponseTest extends ResponseTestCase { public function testConstruction() { @@ -145,4 +145,9 @@ public function getSampleXAccelMappings() array('/home/foo/bar.txt', '/files/=/var/www/,/baz/=/home/foo/', '/baz/bar.txt'), ); } + + protected function provideResponse() + { + return new BinaryFileResponse('README.md'); + } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php index 721cc3cd9e77..f4c9ec157450 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php @@ -134,11 +134,12 @@ public function testCookieIsCleared() 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; domain=.myfoodomain.com; secure; httponly', $cookie->__toString(), '->__toString() returns string representation of the cookie'); + $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'); - $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/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php index 7fd2f5e6d004..f6ea340091ba 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php @@ -63,6 +63,32 @@ public function testFileUploadsWithUnknownMimeType() $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( @@ -197,7 +223,8 @@ public function testIsValid() 'original.gif', null, filesize(__DIR__.'/Fixtures/test.gif'), - UPLOAD_ERR_OK + UPLOAD_ERR_OK, + true ); $this->assertTrue($file->isValid()); @@ -229,4 +256,17 @@ public function uploadedFileErrorProvider() 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/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php index 5b94bd2bd01a..726ba6a34795 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php @@ -31,6 +31,9 @@ public function testIpv4Provider() 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')), ); } @@ -54,6 +57,9 @@ public function testIpv6Provider() 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')), ); } @@ -62,6 +68,10 @@ public function testIpv6Provider() */ 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".'); } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 6a0c16d2d2d6..5ba94f7ed750 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -17,15 +17,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase { - public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - /** * @covers Symfony\Component\HttpFoundation\Request::__construct */ @@ -675,7 +666,41 @@ public function testGetHost() $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.exemple.com', 'HTTP_HOST' => 'www.host.com')); $this->assertEquals('www.host.com', $request->getHost(), '->getHost() value from Host header has priority over SERVER_NAME '); - $this->stopTrustingProxyData(); + } + + 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' + )); + $port = $request->getPort(); + + $this->assertEquals(8443, $port, 'With PROTO and PORT set PORT takes precedence.'); + + $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( + 'HTTP_X_FORWARDED_PROTO' => 'https' + )); + $port = $request->getPort(); + + $this->assertEquals(443, $port, 'With only PROTO set getPort() defaults to 443.'); + + $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( + 'HTTP_X_FORWARDED_PROTO' => 'http' + )); + $port = $request->getPort(); + + $this->assertEquals(80, $port, 'If X_FORWARDED_PROTO is set to http return 80.'); + Request::setTrustedProxies(array()); } /** @@ -748,44 +773,74 @@ public function testGetSetMethod() } /** - * @dataProvider testGetClientIpProvider + * @dataProvider testGetClientIpsProvider */ - public function testGetClientIp($expected, $proxy, $remoteAddr, $httpForwardedFor, $trustedProxies) + public function testGetClientIp($expected, $remoteAddr, $httpForwardedFor, $trustedProxies) { - $request = new Request(); + $request = $this->getRequestInstanceForClientIpTests($remoteAddr, $httpForwardedFor, $trustedProxies); - $server = array('REMOTE_ADDR' => $remoteAddr); - if (null !== $httpForwardedFor) { - $server['HTTP_X_FORWARDED_FOR'] = $httpForwardedFor; - } + $this->assertEquals($expected[0], $request->getClientIp()); - if ($proxy || $trustedProxies) { - Request::setTrustedProxies(null === $trustedProxies ? array($remoteAddr) : $trustedProxies); - } + Request::setTrustedProxies(array()); + } - $request->initialize(array(), array(), array(), array(), array(), $server); - if ($proxy) { - set_error_handler(array($this, "deprecationErrorHandler")); - $this->startTrustingProxyData(); - restore_error_handler(); - } - $this->assertEquals($expected, $request->getClientIp($proxy)); + /** + * @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 testGetClientIpProvider() + public function testGetClientIpsProvider() { + // $expected $remoteAddr $httpForwardedFor $trustedProxies return array( - array('88.88.88.88', false, '88.88.88.88', null, null), - array('127.0.0.1', false, '127.0.0.1', null, null), - array('::1', false, '::1', null, null), - array('127.0.0.1', false, '127.0.0.1', '88.88.88.88', null), - array('88.88.88.88', true, '127.0.0.1', '88.88.88.88', null), - array('2620:0:1cfe:face:b00c::3', true, '::1', '2620:0:1cfe:face:b00c::3', null), - array('88.88.88.88', true, '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', null), - array('87.65.43.21', true, '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', array('123.45.67.89', '88.88.88.88')), - array('87.65.43.21', false, '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', array('123.45.67.89', '88.88.88.88')), + // 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')), ); } @@ -884,8 +939,6 @@ public function testCreateFromGlobals($method) public function testOverrideGlobals() { - set_error_handler(array($this, "deprecationErrorHandler")); - $request = new Request(); $request->initialize(array('foo' => 'bar')); @@ -903,7 +956,6 @@ public function testOverrideGlobals() $this->assertArrayNotHasKey('HTTP_X_FORWARDED_PROTO', $_SERVER); - $this->startTrustingProxyData(); $request->headers->set('X_FORWARDED_PROTO', 'https'); Request::setTrustedProxies(array('1.1.1.1')); @@ -916,8 +968,6 @@ public function testOverrideGlobals() // restore initial $_SERVER array $_SERVER = $server; - - restore_error_handler(); } public function testGetScriptName() @@ -1166,32 +1216,6 @@ public function testToString() $this->assertContains('Accept-Language: zh, en-us; q=0.8, en; q=0.6', $request->__toString()); } - /** - * @dataProvider splitHttpAcceptHeaderData - */ - public function testSplitHttpAcceptHeader($acceptHeader, $expected) - { - $request = new Request(); - - set_error_handler(array($this, "deprecationErrorHandler")); - $this->assertEquals($expected, $request->splitHttpAcceptHeader($acceptHeader)); - restore_error_handler(); - } - - public function splitHttpAcceptHeaderData() - { - return array( - array(null, array()), - array('text/html;q=0.8', array('text/html' => 0.8)), - array('text/html;foo=bar;q=0.8 ', array('text/html;foo=bar' => 0.8)), - array('text/html;charset=utf-8; q=0.8', array('text/html;charset=utf-8' => 0.8)), - array('text/html,application/xml;q=0.9,*/*;charset=utf-8; q=0.8', array('text/html' => 1.0, 'application/xml' => 0.9, '*/*;charset=utf-8' => 0.8)), - array('text/html,application/xhtml+xml;q=0.9,*/*;q=0.8; foo=bar', array('text/html' => 1.0, 'application/xhtml+xml' => 0.9, '*/*;foo=bar' => 0.8)), - array('text/html,application/xhtml+xml;charset=utf-8;q=0.9; foo=bar,*/*', array('text/html' => 1.0, '*/*' => 1.0, 'application/xhtml+xml;charset=utf-8;foo=bar' => 0.9)), - array('text/html,application/xhtml+xml', array('text/html' => 1.0, 'application/xhtml+xml' => 1.0)), - ); - } - public function testIsMethod() { $request = new Request(); @@ -1208,11 +1232,6 @@ public function testIsMethod() $this->assertFalse($request->isMethod('post')); } - private function startTrustingProxyData() - { - Request::trustProxyData(); - } - /** * @dataProvider getBaseUrlData */ @@ -1307,20 +1326,30 @@ public function urlencodedStringPrefixData() ); } - private function stopTrustingProxyData() + private function disableHttpMethodParameterOverride() { $class = new \ReflectionClass('Symfony\\Component\\HttpFoundation\\Request'); - $property = $class->getProperty('trustProxy'); + $property = $class->getProperty('httpMethodParameterOverride'); $property->setAccessible(true); $property->setValue(false); } - private function disableHttpMethodParameterOverride() + private function getRequestInstanceForClientIpTests($remoteAddr, $httpForwardedFor, $trustedProxies) { - $class = new \ReflectionClass('Symfony\\Component\\HttpFoundation\\Request'); - $property = $class->getProperty('httpMethodParameterOverride'); - $property->setAccessible(true); - $property->setValue(false); + $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() @@ -1342,15 +1371,6 @@ public function testTrustedProxies() $this->assertEquals(80, $request->getPort()); $this->assertFalse($request->isSecure()); - // trusted proxy via deprecated trustProxyData() - set_error_handler(array($this, "deprecationErrorHandler")); - Request::trustProxyData(); - $this->assertEquals('2.2.2.2', $request->getClientIp()); - $this->assertEquals('real.example.com', $request->getHost()); - $this->assertEquals(443, $request->getPort()); - $this->assertTrue($request->isSecure()); - restore_error_handler(); - // disabling proxy trusting Request::setTrustedProxies(array()); $this->assertEquals('3.3.3.3', $request->getClientIp()); @@ -1387,6 +1407,99 @@ public function testTrustedProxies() // 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'); + } + + /** + * @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' + ) + ); } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php index c3dd9a27fc71..1cb327860d22 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php @@ -114,11 +114,11 @@ public function testToStringIncludesCookieHeaders() $bag = new ResponseHeaderBag(array()); $bag->setCookie(new Cookie('foo', 'bar')); - $this->assertContains("Set-Cookie: foo=bar; httponly", explode("\r\n", $bag->__toString())); + $this->assertContains("Set-Cookie: foo=bar; path=/; httponly", explode("\r\n", $bag->__toString())); $bag->clearCookie('foo'); - $this->assertContains("Set-Cookie: foo=deleted; expires=".gmdate("D, d-M-Y H:i:s T", time() - 31536001)."; httponly", explode("\r\n", $bag->__toString())); + $this->assertContains("Set-Cookie: foo=deleted; expires=".gmdate("D, d-M-Y H:i:s T", time() - 31536001)."; path=/; httponly", explode("\r\n", $bag->__toString())); } public function testReplace() @@ -158,7 +158,7 @@ public function testCookiesWithSameNames() $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; 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'])); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 28b9d5373258..3a084954c443 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -14,7 +14,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class ResponseTest extends \PHPUnit_Framework_TestCase +class ResponseTest extends ResponseTestCase { public function testCreate() { @@ -326,75 +326,6 @@ public function testContentTypeCharset() $this->assertEquals('text/css; charset=UTF-8', $response->headers->get('Content-Type')); } - 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 = new Response(); - $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 = new Response(); - $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 = new Response(); - $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 = new Response(); - $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 = new Response(); - $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 = new Response(); - $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 = new Response(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertTrue($response->headers->has('Cache-Control')); - } - public function testPrepareDoesNothingIfContentTypeIsSet() { $response = new Response('foo'); @@ -770,6 +701,11 @@ protected function createDateTimeNow() { return new \DateTime(); } + + protected function provideResponse() + { + return new Response(); + } } class StringableObject diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTestCase.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTestCase.php new file mode 100644 index 000000000000..94c770a894ba --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTestCase.php @@ -0,0 +1,88 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Tests; + +use Symfony\Component\HttpFoundation\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/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php index 622d65bc3f12..c11d0d65136f 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php @@ -160,8 +160,10 @@ public function attributesProvider() 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), diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php index 208a5e705b12..1dbfd2f0e9a0 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php @@ -133,20 +133,6 @@ public function testPeekAll() ); } - /** - * @covers Symfony\Component\HttpFoundation\Session\Flash\FlashBag::count - * @expectedException \PHPUnit_Framework_Error_Deprecated - */ - public function testCount() - { - $flashes = array('hello' => 'world', 'beep' => 'boop', 'notice' => 'nope'); - foreach ($flashes as $key => $val) { - $this->bag->set($key, $val); - } - - $this->assertEquals(count($flashes), count($this->bag)); - } - /** * @covers Symfony\Component\HttpFoundation\Session\Flash\FlashBag::getIterator */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php index 2c5b70ec0fd9..9d5ad352845b 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php @@ -47,15 +47,6 @@ protected function tearDown() $this->session = null; } - public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - public function testStart() { $this->assertEquals('', $this->session->getId()); @@ -199,103 +190,6 @@ public function testGetFlashBag() $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface', $this->session->getFlashBag()); } - // deprecated since 2.1, will be removed from 2.3 - - public function testGetSetFlashes() - { - set_error_handler(array($this, "deprecationErrorHandler")); - - $array = array('notice' => 'hello', 'error' => 'none'); - $this->assertEquals(array(), $this->session->getFlashes()); - $this->session->setFlashes($array); - $this->assertEquals($array, $this->session->getFlashes()); - $this->assertEquals(array(), $this->session->getFlashes()); - $this->session->getFlashBag()->add('notice', 'foo'); - - // test that BC works by only retrieving the first added. - $this->session->getFlashBag()->add('notice', 'foo2'); - $this->assertEquals(array('notice' => 'foo'), $this->session->getFlashes()); - - restore_error_handler(); - } - - public function testGetFlashesWithArray() - { - set_error_handler(array($this, "deprecationErrorHandler")); - - $array = array('notice' => 'hello', 'error' => 'none'); - $this->assertEquals(array(), $this->session->getFlashes()); - $this->session->setFlash('foo', $array); - $this->assertEquals(array('foo' => $array), $this->session->getFlashes()); - $this->assertEquals(array(), $this->session->getFlashes()); - - $array = array('hello', 'foo'); - $this->assertEquals(array(), $this->session->getFlashes()); - $this->session->setFlash('foo', $array); - $this->assertEquals(array('foo' => 'hello'), $this->session->getFlashes()); - $this->assertEquals(array(), $this->session->getFlashes()); - - restore_error_handler(); - } - - public function testGetSetFlash() - { - set_error_handler(array($this, "deprecationErrorHandler")); - - $this->assertNull($this->session->getFlash('notice')); - $this->assertEquals('default', $this->session->getFlash('notice', 'default')); - $this->session->getFlashBag()->add('notice', 'foo'); - $this->session->getFlashBag()->add('notice', 'foo2'); - - // test that BC works by only retrieving the first added. - $this->assertEquals('foo', $this->session->getFlash('notice')); - $this->assertNull($this->session->getFlash('notice')); - - restore_error_handler(); - } - - public function testHasFlash() - { - set_error_handler(array($this, "deprecationErrorHandler")); - - $this->assertFalse($this->session->hasFlash('notice')); - $this->session->setFlash('notice', 'foo'); - $this->assertTrue($this->session->hasFlash('notice')); - - restore_error_handler(); - } - - public function testRemoveFlash() - { - set_error_handler(array($this, "deprecationErrorHandler")); - - $this->session->setFlash('notice', 'foo'); - $this->session->setFlash('error', 'bar'); - $this->assertTrue($this->session->hasFlash('notice')); - $this->session->removeFlash('error'); - $this->assertTrue($this->session->hasFlash('notice')); - $this->assertFalse($this->session->hasFlash('error')); - - restore_error_handler(); - } - - public function testClearFlashes() - { - set_error_handler(array($this, "deprecationErrorHandler")); - - $this->assertFalse($this->session->hasFlash('notice')); - $this->assertFalse($this->session->hasFlash('error')); - $this->session->setFlash('notice', 'foo'); - $this->session->setFlash('error', 'bar'); - $this->assertTrue($this->session->hasFlash('notice')); - $this->assertTrue($this->session->hasFlash('error')); - $this->session->clearFlashes(); - $this->assertFalse($this->session->hasFlash('notice')); - $this->assertFalse($this->session->hasFlash('error')); - - restore_error_handler(); - } - /** * @covers Symfony\Component\HttpFoundation\Session\Session::getIterator */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index ff1565a183a9..1abf3844c6fd 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -24,10 +24,48 @@ protected function setUp() } $this->pdo = new \PDO("sqlite::memory:"); + $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $sql = "CREATE TABLE sessions (sess_id VARCHAR(255) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)"; $this->pdo->exec($sql); } + public function testIncompleteOptions() + { + $this->setExpectedException('InvalidArgumentException'); + $storage = new PdoSessionHandler($this->pdo, array(), 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(255) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)"); + + $this->setExpectedException('InvalidArgumentException'); + $storage = new PdoSessionHandler($pdo, array('db_table' => 'sessions'), array()); + } + + public function testWrongTableOptionsWrite() + { + $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'bad_name'), array()); + $this->setExpectedException('RuntimeException'); + $storage->write('foo', 'bar'); + } + + public function testWrongTableOptionsRead() + { + $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'bad_name'), array()); + $this->setExpectedException('RuntimeException'); + $storage->read('foo', 'bar'); + } + + public function testWriteRead() + { + $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array()); + $storage->write('foo', 'bar'); + $this->assertEquals('bar', $storage->read('foo'), 'written value can be read back correctly'); + } + public function testMultipleInstances() { $storage1 = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array()); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index b99941aa2c08..bf515c79a626 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -11,11 +11,15 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; +use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler; use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler; use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler; use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; +use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; +use Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy; +use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy; /** * Test class for NativeSessionStorage. @@ -28,6 +32,28 @@ */ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase { + private $savePath; + + protected function setUp() + { + ini_set('session.save_handler', 'files'); + ini_set('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 * @@ -75,7 +101,6 @@ public function testRegenerate() $storage->regenerate(); $this->assertNotEquals($id, $storage->getId()); $this->assertEquals(7, $storage->getBag('attributes')->get('lucky')); - } public function testRegenerateDestroy() @@ -126,32 +151,132 @@ public function testCookieOptions() $this->assertEquals($options, $gco); } - public function testSetSaveHandler() + /** + * @expectedException \InvalidArgumentException + */ + public function testSetSaveHandlerException() { $storage = $this->getStorage(); - $storage->setSaveHandler(new \StdClass()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); + $storage->setSaveHandler(new \StdClass); } - public function testSetSaveHandlerPHP53() + public function testSetSaveHandler53() { if (version_compare(phpversion(), '5.4.0', '>=')) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } + ini_set('session.save_handler', 'files'); $storage = $this->getStorage(); - $storage->setSaveHandler(new NativeFileSessionHandler()); + $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 SessionHandler())); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); + $storage->setSaveHandler(new SessionHandler()); + $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 testSetSaveHandlerPHP54() + public function testSetSaveHandler54() { if (version_compare(phpversion(), '5.4.0', '<')) { - $this->markTestSkipped('Test skipped, for PHP 5.4+ only.'); + $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } + ini_set('session.save_handler', 'files'); $storage = $this->getStorage(); - $storage->setSaveHandler(new NullSessionHandler()); + $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 SessionHandler())); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); + $storage->setSaveHandler(new SessionHandler()); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); + } + + /** + * @expectedException \RuntimeException + */ + public function testStartedOutside53() + { + if (version_compare(phpversion(), '5.4.0', '>=')) { + $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); + } + + $storage = $this->getStorage(); + + $this->assertFalse(isset($_SESSION)); + + session_start(); + $this->assertTrue(isset($_SESSION)); + // 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(); + } + + /** + * @expectedException \RuntimeException + */ + public function testCanStartOutside54() + { + if (version_compare(phpversion(), '5.4.0', '<')) { + $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); + } + + $storage = $this->getStorage(); + + $this->assertFalse(isset($_SESSION)); + $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->assertFalse(isset($_SESSION[$key])); + $storage->start(); + } +} + +class SessionHandler 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) + { } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php new file mode 100644 index 000000000000..a0663910cab0 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php @@ -0,0 +1,124 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; + +use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler; +use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage; +use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; + +/** + * Test class for PhpSessionStorage. + * + * @author Drak <drak@zikula.org> + * + * These tests require separate processes. + * + * @runTestsInSeparateProcesses + */ +class PhpSessionStorageTest extends \PHPUnit_Framework_TestCase +{ + private $savePath; + + protected function setUp() + { + ini_set('session.save_handler', 'files'); + ini_set('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 (version_compare(phpversion(), '5.4.0', '>=')) { + $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 (version_compare(phpversion(), '5.4.0', '<')) { + $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); + } + + $storage = $this->getStorage(); + + $this->assertFalse(isset($_SESSION)); + $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/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php index dedbde34deae..6b8bba0d5b0d 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php @@ -86,19 +86,54 @@ public function testIsWrapper() $this->assertFalse($this->proxy->isWrapper()); } - public function testIsActive() + public function testIsActivePhp53() { + if (version_compare(phpversion(), '5.4.0', '>=')) { + $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); + } + + $this->assertFalse($this->proxy->isActive()); + } + + /** + * @runInSeparateProcess + */ + public function testIsActivePhp54() + { + if (version_compare(phpversion(), '5.4.0', '<')) { + $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); + } + $this->assertFalse($this->proxy->isActive()); + session_start(); + $this->assertTrue($this->proxy->isActive()); } - public function testSetActive() + public function testSetActivePhp53() { + if (version_compare(phpversion(), '5.4.0', '>=')) { + $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 + * @expectedException \LogicException + */ + public function testSetActivePhp54() + { + if (version_compare(phpversion(), '5.4.0', '<')) { + $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); + } + + $this->proxy->setActive(true); + } + /** * @runInSeparateProcess */ @@ -113,12 +148,30 @@ public function testName() /** * @expectedException \LogicException */ - public function testNameException() + public function testNameExceptionPhp53() { + if (version_compare(phpversion(), '5.4.0', '>=')) { + $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); + } + $this->proxy->setActive(true); $this->proxy->setName('foo'); } + /** + * @runInSeparateProcess + * @expectedException \LogicException + */ + public function testNameExceptionPhp54() + { + if (version_compare(phpversion(), '5.4.0', '<')) { + $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); + } + + session_start(); + $this->proxy->setName('foo'); + } + /** * @runInSeparateProcess */ @@ -133,9 +186,27 @@ public function testId() /** * @expectedException \LogicException */ - public function testIdException() + public function testIdExceptionPhp53() { + if (version_compare(phpversion(), '5.4.0', '>=')) { + $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); + } + $this->proxy->setActive(true); $this->proxy->setId('foo'); } + + /** + * @runInSeparateProcess + * @expectedException \LogicException + */ + public function testIdExceptionPhp54() + { + if (version_compare(phpversion(), '5.4.0', '<')) { + $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); + } + + session_start(); + $this->proxy->setId('foo'); + } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php index bae5390126ba..74d841906025 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php @@ -23,7 +23,7 @@ class SessionHandlerProxyTest extends \PHPUnit_Framework_TestCase { /** - * @var PHPUnit_Framework_MockObject_Matcher + * @var \PHPUnit_Framework_MockObject_Matcher */ private $mock; @@ -52,7 +52,11 @@ public function testOpen() $this->assertFalse($this->proxy->isActive()); $this->proxy->open('name', 'id'); - $this->assertTrue($this->proxy->isActive()); + if (version_compare(phpversion(), '5.4.0', '<')) { + $this->assertTrue($this->proxy->isActive()); + } else { + $this->assertFalse($this->proxy->isActive()); + } } public function testOpenFalse() diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json index 09b8725308d8..f77e08ebd6ac 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json @@ -26,7 +26,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md index fc47662b4397..c06dd3fa57e0 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md @@ -1,6 +1,18 @@ CHANGELOG ========= +2.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 ----- @@ -12,7 +24,7 @@ CHANGELOG * 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 + * updated the MemoryDataCollector to include the memory used in the kernel.terminate event listeners * moved the Stopwatch classes to a new component * added TraceableControllerResolver diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php index 6c896749a3a8..bb427b35af22 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php @@ -13,6 +13,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\BrowserKit\Client as BaseClient; use Symfony\Component\BrowserKit\Request as DomRequest; use Symfony\Component\BrowserKit\Response as DomResponse; @@ -49,6 +50,26 @@ public function __construct(HttpKernelInterface $kernel, array $server = array() $this->followRedirects = false; } + /** + * {@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. * @@ -100,7 +121,7 @@ protected function getScript($request) /** * Converts the BrowserKit request to a HttpKernel request. * - * @param DomRequest $request A Request instance + * @param DomRequest $request A DomRequest instance * * @return Request A Request instance */ @@ -167,7 +188,7 @@ protected function filterFiles(array $files) * * @param Response $response A Response instance * - * @return Response A Response instance + * @return DomResponse A DomResponse instance */ protected function filterResponse($response) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Config/FileLocator.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Config/FileLocator.php index d241b9da1943..47b543c15eeb 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Config/FileLocator.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Config/FileLocator.php @@ -28,14 +28,16 @@ class FileLocator extends BaseFileLocator * Constructor. * * @param KernelInterface $kernel A KernelInterface instance - * @param string $path The path the global resource directory - * @param string|array $paths A path or an array of paths where to look for resources + * @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; - $this->path = $path; - $paths[] = $path; + if (null !== $path) { + $this->path = $path; + $paths[] = $path; + } parent::__construct($paths); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php index bbe77467340f..047ade1062ca 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php @@ -76,13 +76,13 @@ public function getController(Request $request) } } - list($controller, $method) = $this->createController($controller); + $callable = $this->createController($controller); - if (!method_exists($controller, $method)) { - throw new \InvalidArgumentException(sprintf('Method "%s::%s" does not exist.', get_class($controller), $method)); + if (!is_callable($callable)) { + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable.', $request->getPathInfo())); } - return array($controller, $method); + return $callable; } /** diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 9475431816e7..47529fd19048 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -56,21 +56,22 @@ public function setKernel(KernelInterface $kernel = null) 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'), - 'bundles' => array(), - 'sapi_name' => php_sapi_name() + '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)) { @@ -180,6 +181,16 @@ public function hasApc() return $this->data['apc_enabled']; } + /** + * Returns true if Zend OPcache is enabled + * + * @return Boolean true if Zend OPcache is enabled, false otherwise + */ + public function hasZendOpcache() + { + return $this->data['zend_opcache_enabled']; + } + /** * Returns true if XCache is enabled. * @@ -207,7 +218,7 @@ public function hasWinCache() */ public function hasAccelerator() { - return $this->hasApc() || $this->hasEAccelerator() || $this->hasXCache() || $this->hasWinCache(); + return $this->hasApc() || $this->hasZendOpcache() || $this->hasEAccelerator() || $this->hasXCache() || $this->hasWinCache(); } public function getBundles() diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php index 649c88d7643d..5540a1b27ac9 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php @@ -23,7 +23,10 @@ class MemoryDataCollector extends DataCollector { public function __construct() { - $this->data = array('memory' => 0); + $this->data = array( + 'memory' => 0, + 'memory_limit' => $this->convertToBytes(strtolower(ini_get('memory_limit'))), + ); } /** @@ -44,6 +47,16 @@ public function getMemory() return $this->data['memory']; } + /** + * Gets the PHP memory limit. + * + * @return integer The memory limit + */ + public function getMemoryLimit() + { + return $this->data['memory_limit']; + } + /** * Updates the memory usage data. */ @@ -59,4 +72,20 @@ public function getName() { return 'memory'; } + + private function convertToBytes($memoryLimit) + { + if ('-1' === $memoryLimit) { + return -1; + } + + if (preg_match('#^\+?(0x?)?(.*?)([kmg]?)$#', $memoryLimit, $match)) { + $shifts = array('' => 0, 'k' => 10, 'm' => 20, 'g' => 30); + $bases = array('' => 10, '0' => 8, '0x' => 16); + + return intval($match[2], $bases[$match[1]]) << $shifts[$match[3]]; + } + + return 0; + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index 8c002a87cd20..934c8477a528 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -79,11 +79,14 @@ public function collect(Request $request, Response $response, \Exception $except } } + $statusCode = $response->getStatusCode(); + $this->data = array( 'format' => $request->getRequestFormat(), 'content' => $content, 'content_type' => $response->headers->get('Content-Type') ? $response->headers->get('Content-Type') : 'text/html', - 'status_code' => $response->getStatusCode(), + '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(), @@ -130,7 +133,13 @@ public function collect(Request $request, Response $response, \Exception $except } } } elseif ($controller instanceof \Closure) { - $this->data['controller'] = 'Closure'; + $r = new \ReflectionFunction($controller); + $this->data['controller'] = array( + 'class' => $r->getName(), + 'method' => null, + 'file' => $r->getFilename(), + 'line' => $r->getStartLine(), + ); } else { $this->data['controller'] = (string) $controller ?: 'n/a'; } @@ -203,6 +212,11 @@ public function getContentType() return $this->data['content_type']; } + public function getStatusText() + { + return $this->data['status_text']; + } + public function getStatusCode() { return $this->data['status_code']; diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php index 5fd237849903..b9a20aded5a4 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php @@ -35,8 +35,14 @@ public function __construct(KernelInterface $kernel = null) */ 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( - 'start_time' => (null !== $this->kernel ? $this->kernel->getStartTime() : $_SERVER['REQUEST_TIME']) * 1000, + 'start_time' => $startTime * 1000, 'events' => array(), ); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ErrorHandler.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ErrorHandler.php index 3c1cf72d2d7c..2718f891df2d 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ErrorHandler.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ErrorHandler.php @@ -11,118 +11,15 @@ namespace Symfony\Component\HttpKernel\Debug; -use Symfony\Component\HttpKernel\Exception\FatalErrorException; -use Psr\Log\LoggerInterface; +use Symfony\Component\Debug\ErrorHandler as DebugErrorHandler; /** * ErrorHandler. * * @author Fabien Potencier <fabien@symfony.com> + * + * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead. */ -class ErrorHandler +class ErrorHandler extends DebugErrorHandler { - const TYPE_DEPRECATION = -100; - - private $levels = array( - E_WARNING => 'Warning', - E_NOTICE => 'Notice', - E_USER_ERROR => 'User Error', - E_USER_WARNING => 'User Warning', - E_USER_NOTICE => 'User Notice', - E_STRICT => 'Runtime Notice', - E_RECOVERABLE_ERROR => 'Catchable Fatal Error', - E_DEPRECATED => 'Deprecated', - E_USER_DEPRECATED => 'User Deprecated', - E_ERROR => 'Error', - E_CORE_ERROR => 'Core Error', - E_COMPILE_ERROR => 'Compile Error', - E_PARSE => 'Parse', - ); - - private $level; - - private $reservedMemory; - - /** @var LoggerInterface */ - private static $logger; - - /** - * Register the error handler. - * - * @param integer $level The level at which the conversion to Exception is done (null to use the error_reporting() value and 0 to disable) - * - * @return The registered error handler - */ - public static function register($level = null) - { - $handler = new static(); - $handler->setLevel($level); - - ini_set('display_errors', 0); - set_error_handler(array($handler, 'handle')); - register_shutdown_function(array($handler, 'handleFatal')); - $handler->reservedMemory = str_repeat('x', 10240); - - return $handler; - } - - public function setLevel($level) - { - $this->level = null === $level ? error_reporting() : $level; - } - - public static function setLogger(LoggerInterface $logger) - { - self::$logger = $logger; - } - - /** - * @throws \ErrorException When error_reporting returns error - */ - public function handle($level, $message, $file, $line, $context) - { - if (0 === $this->level) { - return false; - } - - if ($level & (E_USER_DEPRECATED | E_DEPRECATED)) { - if (null !== self::$logger) { - $stack = version_compare(PHP_VERSION, '5.4', '<') ? array_slice(debug_backtrace(false), 0, 10) : debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10); - - self::$logger->warning($message, array('type' => self::TYPE_DEPRECATION, 'stack' => $stack)); - } - - return true; - } - - if (error_reporting() & $level && $this->level & $level) { - throw new \ErrorException(sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line), 0, $level, $file, $line); - } - - return false; - } - - public function handleFatal() - { - if (null === $error = error_get_last()) { - return; - } - - unset($this->reservedMemory); - $type = $error['type']; - if (0 === $this->level || !in_array($type, array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE))) { - return; - } - - // get current exception handler - $exceptionHandler = set_exception_handler(function() {}); - restore_exception_handler(); - - if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandler) { - $level = isset($this->levels[$type]) ? $this->levels[$type] : $type; - $message = sprintf('%s: %s in %s line %d', $level, $error['message'], $error['file'], $error['line']); - $exception = new FatalErrorException($message, 0, $type, $error['file'], $error['line']); - $exceptionHandler[0]->handle($exception); - } - } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php index a2d0dd42ec9c..581e29cd8498 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php @@ -11,273 +11,15 @@ namespace Symfony\Component\HttpKernel\Debug; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\FlattenException; - -if (!defined('ENT_SUBSTITUTE')) { - define('ENT_SUBSTITUTE', 8); -} +use Symfony\Component\Debug\ExceptionHandler as DebugExceptionHandler; /** * 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 <fabien@symfony.com> + * + * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead. */ -class ExceptionHandler +class ExceptionHandler extends DebugExceptionHandler { - private $debug; - private $charset; - - public function __construct($debug = true, $charset = 'UTF-8') - { - $this->debug = $debug; - $this->charset = $charset; - } - - /** - * Register the exception handler. - * - * @param Boolean $debug - * - * @return ExceptionHandler The registered exception handler - */ - public static function register($debug = true) - { - $handler = new static($debug); - - set_exception_handler(array($handler, 'handle')); - - return $handler; - } - - /** - * Sends a Response for the given Exception. - * - * @param \Exception $exception An \Exception instance - */ - public function handle(\Exception $exception) - { - $this->createResponse($exception)->send(); - } - - /** - * 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 new Response($this->decorate($this->getContent($exception), $this->getStylesheet($exception)), $exception->getStatusCode(), $exception->getHeaders()); - } - - /** - * 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->abbrClass($e['class']); - $message = nl2br($e['message']); - $content .= sprintf(<<<EOF - <div class="block_exception clear_fix"> - <h2><span>%d/%d</span> %s: %s</h2> - </div> - <div class="block"> - <ol class="traces list_exception"> - -EOF - , $ind, $total, $class, $message); - foreach ($e['trace'] as $trace) { - $content .= ' <li>'; - if ($trace['function']) { - $content .= sprintf('at %s%s%s(%s)', $this->abbrClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args'])); - } - if (isset($trace['file']) && isset($trace['line'])) { - if ($linkFormat = ini_get('xdebug.file_link_format')) { - $link = str_replace(array('%f', '%l'), array($trace['file'], $trace['line']), $linkFormat); - $content .= sprintf(' in <a href="%s" title="Go to source">%s line %s</a>', $link, $trace['file'], $trace['line']); - } else { - $content .= sprintf(' in %s line %s', $trace['file'], $trace['line']); - } - } - $content .= "</li>\n"; - } - - $content .= " </ol>\n</div>\n"; - } - } catch (\Exception $e) { - // something nasty happened and we cannot throw an exception anymore - if ($this->debug) { - $title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($exception), $exception->getMessage()); - } else { - $title = 'Whoops, looks like something went wrong.'; - } - } - } - - return <<<EOF - <div id="sf-resetcontent" class="sf-reset"> - <h1>$title</h1> - $content - </div> -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 <<<EOF - .sf-reset { font: 11px Verdana, Arial, sans-serif; color: #333 } - .sf-reset .clear { clear:both; height:0; font-size:0; line-height:0; } - .sf-reset .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; } - .sf-reset .clear_fix { display:inline-block; } - .sf-reset * html .clear_fix { height:1%; } - .sf-reset .clear_fix { display:block; } - .sf-reset, .sf-reset .block { margin: auto } - .sf-reset abbr { border-bottom: 1px dotted #000; cursor: help; } - .sf-reset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px } - .sf-reset strong { font-weight:bold; } - .sf-reset a { color:#6c6159; } - .sf-reset a img { border:none; } - .sf-reset a:hover { text-decoration:underline; } - .sf-reset em { font-style:italic; } - .sf-reset h1, .sf-reset h2 { font: 20px Georgia, "Times New Roman", Times, serif } - .sf-reset h2 span { background-color: #fff; color: #333; padding: 6px; float: left; margin-right: 10px; } - .sf-reset .traces li { font-size:12px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; } - .sf-reset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px; - -webkit-border-bottom-right-radius: 16px; - -webkit-border-bottom-left-radius: 16px; - -moz-border-radius-bottomright: 16px; - -moz-border-radius-bottomleft: 16px; - border-bottom-right-radius: 16px; - border-bottom-left-radius: 16px; - border-bottom:1px solid #ccc; - border-right:1px solid #ccc; - border-left:1px solid #ccc; - } - .sf-reset .block_exception { background-color:#ddd; color: #333; padding:20px; - -webkit-border-top-left-radius: 16px; - -webkit-border-top-right-radius: 16px; - -moz-border-radius-topleft: 16px; - -moz-border-radius-topright: 16px; - border-top-left-radius: 16px; - border-top-right-radius: 16px; - border-top:1px solid #ccc; - border-right:1px solid #ccc; - border-left:1px solid #ccc; - overflow: hidden; - word-wrap: break-word; - } - .sf-reset li a { background:none; color:#868686; text-decoration:none; } - .sf-reset li a:hover { background:none; color:#313131; text-decoration:underline; } - .sf-reset ol { padding: 10px 0; } - .sf-reset h1 { background-color:#FFFFFF; padding: 15px 28px; margin-bottom: 20px; - -webkit-border-radius: 10px; - -moz-border-radius: 10px; - border-radius: 10px; - border: 1px solid #ccc; - } -EOF; - } - - private function decorate($content, $css) - { - return <<<EOF -<!DOCTYPE html> -<html> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> - <meta name="robots" content="noindex,nofollow" /> - <style> - /* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */ - html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;} - - html { background: #eee; padding: 10px } - img { border: 0; } - #sf-resetcontent { width:970px; margin:0 auto; } - $css - </style> - </head> - <body> - $content - </body> -</html> -EOF; - } - - private function abbrClass($class) - { - $parts = explode('\\', $class); - - return sprintf("<abbr title=\"%s\">%s</abbr>", $class, array_pop($parts)); - } - - /** - * 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("<em>object</em>(%s)", $this->abbrClass($item[1])); - } elseif ('array' === $item[0]) { - $formattedValue = sprintf("<em>array</em>(%s)", is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]); - } elseif ('string' === $item[0]) { - $formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES | ENT_SUBSTITUTE, $this->charset)); - } elseif ('null' === $item[0]) { - $formattedValue = '<em>null</em>'; - } elseif ('boolean' === $item[0]) { - $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>'; - } elseif ('resource' === $item[0]) { - $formattedValue = '<em>resource</em>'; - } else { - $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES | ENT_SUBSTITUTE, $this->charset), true)); - } - - $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); - } - - return implode(', ', $result); - } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php index 365bcb8c0318..6bfd7a01dd38 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php @@ -385,9 +385,8 @@ private function preDispatch($eventName, Event $event) case KernelEvents::VIEW: case KernelEvents::RESPONSE: // stop only if a controller has been executed - try { + if ($this->stopwatch->isStarted('controller')) { $this->stopwatch->stop('controller'); - } catch (\LogicException $e) { } break; case KernelEvents::TERMINATE: diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php index 20b4a5e75e9a..18ca8ef2f7bf 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php @@ -18,9 +18,10 @@ use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Scope; /** - * This HttpKernel is used to manage scope changes of the DI container. + * Adds a managed request scope. * * @author Fabien Potencier <fabien@symfony.com> * @author Johannes M. Schmitt <schmittjoh@gmail.com> @@ -41,6 +42,11 @@ public function __construct(EventDispatcherInterface $dispatcher, ContainerInter parent::__construct($dispatcher, $controllerResolver); $this->container = $container; + + // the request scope might have been created before (see FrameworkBundle) + if (!$container->hasScope('request')) { + $container->addScope(new Scope('request')); + } } /** @@ -56,11 +62,13 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ 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/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php new file mode 100644 index 000000000000..ee00fbb6656b --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php @@ -0,0 +1,92 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\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)) { + return; + } + + $definition = $container->getDefinition($this->dispatcherService); + + foreach ($container->findTaggedServiceIds($this->listenerTag) 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 "kernel.event_listener" tags.', $id)); + } + + 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) { + // We must assume that the class value has been correctly filled, even if the service is created by a factory + $class = $container->getDefinition($id)->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/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/DeprecationLoggerListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ErrorsLoggerListener.php similarity index 73% rename from core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/DeprecationLoggerListener.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ErrorsLoggerListener.php index ca2c480582d0..13940ab7ac7b 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/DeprecationLoggerListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ErrorsLoggerListener.php @@ -17,23 +17,27 @@ use Symfony\Component\HttpKernel\KernelEvents; /** - * Injects the logger into the ErrorHandler, so that it can log deprecation errors. + * Injects the logger into the ErrorHandler, so that it can log various errors. * * @author Colin Frei <colin@colinfrei.com> + * @author Konstantin Myakshin <koc-dp@yandex.ru> */ -class DeprecationLoggerListener implements EventSubscriberInterface +class ErrorsLoggerListener implements EventSubscriberInterface { + private $channel; + private $logger; - public function __construct(LoggerInterface $logger = null) + public function __construct($channel, LoggerInterface $logger = null) { + $this->channel = $channel; $this->logger = $logger; } public function injectLogger() { if (null !== $this->logger) { - ErrorHandler::setLogger($this->logger); + ErrorHandler::setLogger($this->logger, $this->channel); } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php index b404de79a7e6..4ee5df4534bd 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php @@ -95,11 +95,12 @@ public static function getSubscribedEvents() 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); + $this->logger->critical($message, $context); } else { - $this->logger->error($message); + $this->logger->error($message, $context); } } elseif (!$original || $isCritical) { error_log($message); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/FragmentListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/FragmentListener.php index 1a4d83b769cd..ef3fad3d4cfe 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/FragmentListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/FragmentListener.php @@ -80,10 +80,8 @@ protected function validateRequest(Request $request) // does the Request come from a trusted IP? $trustedIps = array_merge($this->getLocalIpAddresses(), $request->getTrustedProxies()); $remoteAddress = $request->server->get('REMOTE_ADDR'); - foreach ($trustedIps as $ip) { - if (IpUtils::checkIp($remoteAddress, $ip)) { - return; - } + if (IpUtils::checkIp($remoteAddress, $trustedIps)) { + return; } // is the Request signed? diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php index f3cb80483266..0b864c02f2bc 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\RequestContextAwareInterface; @@ -27,7 +26,6 @@ class LocaleListener implements EventSubscriberInterface { private $router; private $defaultLocale; - private $locales = array(); public function __construct($defaultLocale = 'en', RequestContextAwareInterface $router = null) { @@ -35,24 +33,27 @@ public function __construct($defaultLocale = 'en', RequestContextAwareInterface $this->router = $router; } - public function onKernelResponse(FilterResponseEvent $event) + public function setRequest(Request $request = null) { - array_shift($this->locales); + if (null === $request) { + return; + } - // setting back the locale to the previous value - $locale = isset($this->locales[0]) ? $this->locales[0] : $this->defaultLocale; - $request = $event->getRequest(); - $this->setLocale($request, $locale); + if ($locale = $request->attributes->get('_locale')) { + $request->setLocale($locale); + } + + if (null !== $this->router) { + $this->router->getContext()->setParameter('_locale', $request->getLocale()); + } } public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); - $request->setDefaultLocale($this->defaultLocale); - $this->setLocale($request, $request->attributes->get('_locale', $this->defaultLocale)); - array_unshift($this->locales, $request->getLocale()); + $this->setRequest($request); } public static function getSubscribedEvents() @@ -60,16 +61,6 @@ 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::RESPONSE => 'onKernelResponse', ); } - - private function setLocale(Request $request, $locale) - { - $request->setLocale($locale); - - if (null !== $this->router) { - $this->router->getContext()->setParameter('_locale', $request->getLocale()); - } - } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php index 606b358e72f0..f68716c144f8 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php @@ -23,6 +23,7 @@ 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. @@ -34,6 +35,7 @@ class RouterListener implements EventSubscriberInterface private $matcher; private $context; private $logger; + private $request; /** * Constructor. @@ -59,12 +61,32 @@ public function __construct($matcher, RequestContext $context = null, LoggerInte $this->logger = $logger; } + /** + * Sets the current Request. + * + * The application should call this method whenever the Request + * object changes (entering a Request scope for instance, but + * also when leaving a Request scope -- especially when they are + * nested). + * + * @param Request|null $request A Request instance + */ + public function setRequest(Request $request = null) + { + if (null !== $request && $this->request !== $request) { + $this->context->fromRequest($request); + } + $this->request = $request; + } + 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) - $this->context->fromRequest($request); + // 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 + $this->setRequest($request); if ($request->attributes->has('_controller')) { // routing is already done diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FatalErrorException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FatalErrorException.php index a082f80dc0a0..1f1ef1a276a9 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FatalErrorException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FatalErrorException.php @@ -11,12 +11,15 @@ namespace Symfony\Component\HttpKernel\Exception; +use Symfony\Component\Debug\Exception\FatalErrorException as DebugFatalErrorException; + /** * Fatal Error Exception. * * @author Konstanton Myakshin <koc-dp@yandex.ru> + * + * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead. */ -class FatalErrorException extends \ErrorException +class FatalErrorException extends DebugFatalErrorException { - } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php index 66cafed8da57..0168afca169d 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php @@ -11,265 +11,17 @@ 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 <fabien@symfony.com> + * + * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead. */ -class FlattenException +class FlattenException extends DebugFlattenException { - 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) - { - $trace = $exception->getTrace(); - - if ($exception instanceof FatalErrorException) { - if (function_exists('xdebug_get_function_stack')) { - $trace = array_slice(array_reverse(xdebug_get_function_stack()), 4); - - foreach ($trace as $i => $frame) { - // XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695 - if (!isset($frame['type'])) { - $trace[$i]['type'] = '??'; - } - - if ('dynamic' === $trace[$i]['type']) { - $trace[$i]['type'] = '->'; - } elseif ('static' === $trace[$i]['type']) { - $trace[$i]['type'] = '::'; - } - - // XDebug also has a different name for the parameters array - if (isset($frame['params']) && !isset($frame['args'])) { - $trace[$i]['args'] = $frame['params']; - unset($trace[$i]['params']); - } - } - } else { - $trace = array_slice(array_reverse($trace), 1); - } - } - - $this->setTrace($trace, $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) - { - $result = array(); - foreach ($args as $key => $value) { - 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)); - } - } 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/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php index b4f3f9c1eef4..af9b9ba98b74 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php @@ -15,10 +15,6 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Renders a URI that represents a resource fragment. @@ -30,11 +26,11 @@ * * @see FragmentRendererInterface */ -class FragmentHandler implements EventSubscriberInterface +class FragmentHandler { private $debug; private $renderers; - private $requests; + private $request; /** * Constructor. @@ -49,13 +45,12 @@ public function __construct(array $renderers = array(), $debug = false) $this->addRenderer($renderer); } $this->debug = $debug; - $this->requests = array(); } /** * Adds a renderer. * - * @param FragmentRendererInterface $strategy A FragmentRendererInterface instance + * @param FragmentRendererInterface $renderer A FragmentRendererInterface instance */ public function addRenderer(FragmentRendererInterface $renderer) { @@ -63,23 +58,13 @@ public function addRenderer(FragmentRendererInterface $renderer) } /** - * Stores the Request object. + * Sets the current Request. * - * @param GetResponseEvent $event A GetResponseEvent instance + * @param Request $request The current Request */ - public function onKernelRequest(GetResponseEvent $event) + public function setRequest(Request $request = null) { - array_unshift($this->requests, $event->getRequest()); - } - - /** - * Removes the most recent Request object. - * - * @param FilterResponseEvent $event A FilterResponseEvent instance - */ - public function onKernelResponse(FilterResponseEvent $event) - { - array_shift($this->requests); + $this->request = $request; } /** @@ -108,7 +93,11 @@ public function render($uri, $renderer = 'inline', array $options = array()) throw new \InvalidArgumentException(sprintf('The "%s" renderer does not exist.', $renderer)); } - return $this->deliver($this->renderers[$renderer]->render($uri, $this->requests[0], $options)); + if (null === $this->request) { + throw new \LogicException('Rendering a fragment can only be done when handling a master Request.'); + } + + return $this->deliver($this->renderers[$renderer]->render($uri, $this->request, $options)); } /** @@ -126,7 +115,7 @@ public function render($uri, $renderer = 'inline', array $options = array()) protected function deliver(Response $response) { if (!$response->isSuccessful()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $this->requests[0]->getUri(), $response->getStatusCode())); + throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $this->request->getUri(), $response->getStatusCode())); } if (!$response instanceof StreamedResponse) { @@ -135,41 +124,4 @@ protected function deliver(Response $response) $response->sendContent(); } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::REQUEST => 'onKernelRequest', - KernelEvents::RESPONSE => 'onKernelResponse', - ); - } - - // to be removed in 2.3 - public function fixOptions(array $options) - { - // support for the standalone option is @deprecated in 2.2 and replaced with the strategy option - if (isset($options['standalone'])) { - trigger_error('The "standalone" option is deprecated in version 2.2 and replaced with the "strategy" option.', E_USER_DEPRECATED); - - // support for the true value is @deprecated in 2.2, will be removed in 2.3 - if (true === $options['standalone']) { - trigger_error('The "true" value for the "standalone" option is deprecated in version 2.2 and replaced with the "esi" value.', E_USER_DEPRECATED); - - $options['standalone'] = 'esi'; - } elseif (false === $options['standalone']) { - trigger_error('The "false" value for the "standalone" option is deprecated in version 2.2 and replaced with the "inline" value.', E_USER_DEPRECATED); - - $options['standalone'] = 'inline'; - } elseif ('js' === $options['standalone']) { - trigger_error('The "js" value for the "standalone" option is deprecated in version 2.2 and replaced with the "hinclude" value.', E_USER_DEPRECATED); - - $options['standalone'] = 'hinclude'; - } - - $options['strategy'] = $options['standalone']; - unset($options['standalone']); - } - - return $options; - } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php index fafa76368c85..1f059da94ad2 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -11,6 +11,10 @@ namespace Symfony\Component\HttpKernel\Fragment; +if (!defined('ENT_SUBSTITUTE')) { + define('ENT_SUBSTITUTE', 8); +} + use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Templating\EngineInterface; @@ -27,6 +31,7 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer private $globalDefaultTemplate; private $signer; private $templating; + private $charset; /** * Constructor. @@ -34,18 +39,22 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer * @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) + 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) { @@ -71,7 +80,9 @@ public function hasTemplating() * * Additional available options: * - * * default: The default content (it can be a template name or the content) + * * 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()) { @@ -93,9 +104,29 @@ public function render($uri, Request $request, array $options = array()) $content = $template; } - return new Response(sprintf('<hx:include src="%s">%s</hx:include>', $uri, $content)); + $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) { + foreach($attributes as $attribute => $value) { + $renderedAttributes .= sprintf( + ' %s="%s"', + htmlspecialchars($attribute, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset, false), + htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset, false) + ); + } + } + + return new Response(sprintf('<hx:include src="%s"%s>%s</hx:include>', $uri, $renderedAttributes, $content)); } + /** + * @param string $template + * + * @return boolean + */ private function templateExists($template) { if ($this->templating instanceof EngineInterface) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php index 928d395f0df4..1cbdeab18ea0 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php @@ -15,6 +15,9 @@ 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. @@ -24,15 +27,17 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer { private $kernel; + private $dispatcher; /** * Constructor. * * @param HttpKernelInterface $kernel A HttpKernelInterface instance */ - public function __construct(HttpKernelInterface $kernel) + public function __construct(HttpKernelInterface $kernel, EventDispatcherInterface $dispatcher = null) { $this->kernel = $kernel; + $this->dispatcher = $dispatcher; } /** @@ -61,6 +66,14 @@ public function render($uri, Request $request, array $options = array()) 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 while (ob_get_level() > $level) { ob_get_clean(); @@ -86,10 +99,25 @@ protected function createSubRequest($uri, Request $request) $cookies = $request->cookies->all(); $server = $request->server->all(); - // the sub-request is internal + // 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 { + $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); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategy.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategy.php index c5ec81051fb3..6384af9660a8 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategy.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategy.php @@ -29,13 +29,12 @@ class EsiResponseCacheStrategy implements EsiResponseCacheStrategyInterface { private $cacheable = true; + private $embeddedResponses = 0; private $ttls = array(); private $maxAges = array(); /** - * Adds a Response. - * - * @param Response $response + * {@inheritdoc} */ public function add(Response $response) { @@ -45,26 +44,38 @@ public function add(Response $response) $this->ttls[] = $response->getTtl(); $this->maxAges[] = $response->getMaxAge(); } + + $this->embeddedResponses++; } /** - * Updates the Response HTTP headers based on the embedded Responses. - * - * @param Response $response + * {@inheritdoc} */ public function update(Response $response) { - // if we only have one Response, do nothing - if (1 === count($this->ttls)) { + // 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)); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 69e938881449..63cde7e5b222 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -194,8 +194,6 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ $response = $this->lookup($request, $catch); } - $response->isNotModified($request); - $this->restoreResponseBody($request, $response); $response->setDate(new \DateTime(null, new \DateTimeZone('UTC'))); @@ -205,15 +203,17 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ } if (null !== $this->esi) { - $this->esiCacheStrategy->add($response); - if (HttpKernelInterface::MASTER_REQUEST === $type) { $this->esiCacheStrategy->update($response); + } else { + $this->esiCacheStrategy->add($response); } } $response->prepare($request); + $response->isNotModified($request); + return $response; } @@ -265,6 +265,15 @@ protected function invalidate(Request $request, $catch = false) 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'); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php index 452b9dfe401b..a1cda1fd2709 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php @@ -246,15 +246,6 @@ public function invalidate(Request $request) throw new \RuntimeException('Unable to store the metadata.'); } } - - // As per the RFC, invalidate Location and Content-Location URLs if present - foreach (array('Location', 'Content-Location') as $header) { - if ($uri = $request->headers->get($header)) { - $subRequest = $request::create($uri, 'get', array(), array(), array(), $request->server->all()); - - $this->invalidate($subRequest); - } - } } /** @@ -265,7 +256,7 @@ public function invalidate(Request $request) * @param array $env1 A Request HTTP header array * @param array $env2 A Request HTTP header array * - * @return Boolean true if the the two environments match, false otherwise + * @return Boolean true if the two environments match, false otherwise */ private function requestsMatch($vary, $env1, $env2) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php index 7a63171c7c0f..ae7a44cd4d4f 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php @@ -51,20 +51,8 @@ public function __construct(EventDispatcherInterface $dispatcher, ControllerReso } /** - * 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 integer $type The type of the request - * (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * @param Boolean $catch Whether to catch exceptions or not - * - * @return Response A Response instance - * - * @throws \Exception When an Exception occurs during processing - * + * {@inheritdoc} + * * @api */ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) @@ -155,7 +143,7 @@ private function handleRaw(Request $request, $type = self::MASTER_REQUEST) * Filters a response object. * * @param Response $response A Response instance - * @param Request $request A error message in case the response is not a Response object + * @param Request $request An error message in case the response is not a Response object * @param integer $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) * * @return Response The filtered Response instance diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php index 18950c190b7a..33acb24166dd 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php @@ -11,6 +11,8 @@ 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; @@ -27,13 +29,10 @@ use Symfony\Component\HttpKernel\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; use Symfony\Component\HttpKernel\DependencyInjection\AddClassesToCachePass; -use Symfony\Component\HttpKernel\Debug\ErrorHandler; -use Symfony\Component\HttpKernel\Debug\ExceptionHandler; use Symfony\Component\Config\Loader\LoaderResolver; use Symfony\Component\Config\Loader\DelegatingLoader; use Symfony\Component\Config\ConfigCache; use Symfony\Component\ClassLoader\ClassCollectionLoader; -use Symfony\Component\ClassLoader\DebugClassLoader; /** * The Kernel is the heart of the Symfony system. @@ -60,13 +59,13 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $name; protected $startTime; protected $classes; - protected $errorReportingLevel; + protected $loadClassCache; - const VERSION = '2.2.1'; - const VERSION_ID = '20101'; + const VERSION = '2.3.0'; + const VERSION_ID = '20300'; const MAJOR_VERSION = '2'; - const MINOR_VERSION = '2'; - const RELEASE_VERSION = '1'; + const MINOR_VERSION = '3'; + const RELEASE_VERSION = '0'; const EXTRA_VERSION = ''; /** @@ -94,21 +93,11 @@ public function __construct($environment, $debug) $this->init(); } + /** + * @deprecated Deprecated since version 2.3, to be removed in 3.0. Move your logic in the constructor instead. + */ public function init() { - ini_set('display_errors', 0); - - if ($this->debug) { - error_reporting(-1); - - DebugClassLoader::enable(); - ErrorHandler::register($this->errorReportingLevel); - if ('cli' !== php_sapi_name()) { - ExceptionHandler::register(); - } else { - ini_set('display_errors', 1); - } - } } public function __clone() @@ -132,6 +121,10 @@ public function boot() return; } + if ($this->loadClassCache) { + $this->doLoadClassCache($this->loadClassCache[0], $this->loadClassCache[1]); + } + // init bundles $this->initializeBundles(); @@ -398,14 +391,18 @@ public function getContainer() /** * 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') { - if (!$this->booted && is_file($this->getCacheDir().'/classes.map')) { - ClassCollectionLoader::load(include($this->getCacheDir().'/classes.map'), $this->getCacheDir(), $name, $this->debug, false, $extension); - } + $this->loadClassCache = array($name, $extension); } /** @@ -456,6 +453,13 @@ 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. * @@ -554,6 +558,7 @@ protected function initializeContainer() $fresh = true; if (!$cache->isFresh()) { $container = $this->buildContainer(); + $container->compile(); $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass()); $fresh = false; @@ -636,6 +641,25 @@ protected function buildContainer() } $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)); + + 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()) { @@ -651,19 +675,8 @@ protected function buildContainer() $bundle->build($container); } - $container->addObjectResource($this); - // ensure these extensions are implicitly loaded $container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions)); - - if (null !== $cont = $this->registerContainerConfiguration($this->getContainerLoader($container))) { - $container->merge($cont); - } - - $container->addCompilerPass(new AddClassesToCachePass($this)); - $container->compile(); - - return $container; } /** @@ -673,7 +686,13 @@ protected function buildContainer() */ protected function getContainerBuilder() { - return new ContainerBuilder(new ParameterBag($this->getKernelParameters())); + $container = new ContainerBuilder(new ParameterBag($this->getKernelParameters())); + + if (class_exists('ProxyManager\Configuration')) { + $container->setProxyInstantiator(new RuntimeInstantiator()); + } + + return $container; } /** @@ -688,6 +707,11 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container { // cache the container $dumper = new PhpDumper($container); + + if (class_exists('ProxyManager\Configuration')) { + $dumper->setProxyDumper(new ProxyDumper()); + } + $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass)); if (!$this->debug) { $content = self::stripComments($content); @@ -740,7 +764,7 @@ public static function stripComments($source) if (is_string($token)) { $rawChunk .= $token; } elseif (T_START_HEREDOC === $token[0]) { - $output .= preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $rawChunk) . $token[1]; + $output .= preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $rawChunk).$token[1]; do { $token = next($tokens); $output .= $token[1]; diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php index e3454f60f9a6..69ff9730540e 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php @@ -269,7 +269,7 @@ private function createProfileFromData($token, $data, $parent = null) */ private function getItemName($token) { - $name = self::TOKEN_PREFIX . $token; + $name = self::TOKEN_PREFIX.$token; if ($this->isItemNameValid($name)) { return $name; @@ -285,7 +285,7 @@ private function getItemName($token) */ private function getIndexName() { - $name = self::TOKEN_PREFIX . 'index'; + $name = self::TOKEN_PREFIX.'index'; if ($this->isItemNameValid($name)) { return $name; diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php index dc337789ad16..9265fc13f5c5 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php @@ -60,14 +60,7 @@ public function find($ip, $url, $limit, $method, $start = null, $end = null) fseek($file, 0, SEEK_END); $result = array(); - - for (;$limit > 0; $limit--) { - $line = $this->readLineFromFile($file); - - if (null === $line) { - break; - } - + while (count($result) < $limit && $line = $this->readLineFromFile($file)) { list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent) = str_getcsv($line); $csvTime = (int) $csvTime; @@ -238,12 +231,12 @@ protected function readLineFromFile($file) $buffer = fread($file, $chunkSize); if (false === ($upTo = strrpos($buffer, "\n"))) { - $line = $buffer . $line; + $line = $buffer.$line; continue; } $position += $upTo; - $line = substr($buffer, $upTo + 1) . $line; + $line = substr($buffer, $upTo + 1).$line; fseek($file, max(0, $position), SEEK_SET); if ('' !== $line) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php index b9ab9d118155..a78cec0c8a32 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php @@ -105,6 +105,6 @@ protected function appendValue($key, $value, $expiration = 0) //simulate append in Memcache <3.0 $content = $memcache->get($key); - return $memcache->set($key, $content . $value, false, $expiration); + return $memcache->set($key, $content.$value, false, $expiration); } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php index 56f6865d9097..38a522a3e91f 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php @@ -101,7 +101,7 @@ protected function getMongo() { if ($this->mongo === null) { if (preg_match('#^(mongodb://.*)/(.*)/(.*)$#', $this->dsn, $matches)) { - $server = $matches[1] . (!empty($matches[2]) ? '/' . $matches[2] : ''); + $server = $matches[1].(!empty($matches[2]) ? '/'.$matches[2] : ''); $database = $matches[2]; $collection = $matches[3]; diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php index 606c60de27a2..49f3137e1525 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php @@ -204,7 +204,7 @@ public function collect(Request $request, Response $response, \Exception $except return; } - $profile = new Profile(sha1(uniqid(mt_rand(), true))); + $profile = new Profile(substr(sha1(uniqid(mt_rand(), true)), 0, 6)); $profile->setTime(time()); $profile->setUrl($request->getUri()); $profile->setIp($request->getClientIp()); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php index d55688de8c9a..755d7f614c97 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php @@ -35,6 +35,10 @@ public function testDoRequest() $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'); @@ -114,7 +118,7 @@ public function testUploadedFile() $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), + new UploadedFile($source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true), ); foreach ($files as $file) { @@ -147,7 +151,7 @@ public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() $file = $this ->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') - ->setConstructorArgs(array($source, 'original', 'mime/original', 123, UPLOAD_ERR_OK)) + ->setConstructorArgs(array($source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true)) ->setMethods(array('getSize')) ->getMock() ; diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php new file mode 100755 index 000000000000..be59486269e9 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php @@ -0,0 +1,47 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Tests\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/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php index c19af8216dda..aa401f44d6f4 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php @@ -150,6 +150,16 @@ public function testGetArguments() $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\some_controller_function')); + + $request = Request::create('/'); + $request->attributes->set('_controller', 'foobar'); + $mock->getController($request); + } + public function __invoke($foo, $bar = null) { } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index 5a0166d39ec0..192c8083e027 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -53,6 +53,8 @@ public function testCollect() || (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')))) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php index e02821004e2b..607a580aefc9 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php @@ -26,12 +26,39 @@ protected function setUp() public function testCollect() { - $c = new MemoryDataCollector(); + $collector = new MemoryDataCollector(); + $collector->collect(new Request(), new Response()); - $c->collect(new Request(), new Response()); + $this->assertInternalType('integer', $collector->getMemory()); + $this->assertInternalType('integer', $collector->getMemoryLimit()); + $this->assertSame('memory', $collector->getName()); + } - $this->assertInternalType('integer',$c->getMemory()); - $this->assertSame('memory',$c->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('-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/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php index 10322b132dd6..8c14604b28cd 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php @@ -50,6 +50,7 @@ public function testCollect(Request $request, Response $response) $this->assertEquals('en',$c->getLocale()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\HeaderBag',$c->getResponseHeaders()); + $this->assertEquals('OK',$c->getStatusText()); $this->assertEquals(200,$c->getStatusCode()); $this->assertEquals('application/json',$c->getContentType()); } @@ -80,7 +81,12 @@ public function testControllerInspection(Request $request, Response $response) array( 'Closure', function() { return 'foo'; }, - 'Closure', + array( + 'class' => __NAMESPACE__.'\{closure}', + 'method' => null, + 'file' => __FILE__, + 'line' => __LINE__ - 5, + ), ), array( diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php new file mode 100644 index 000000000000..13abb6769694 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php @@ -0,0 +1,58 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Tests\DataCollector; + +use Symfony\Component\HttpKernel\DataCollector\TimeDataCollector; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; + +class TimeDataCollectorTest extends \PHPUnit_Framework_TestCase +{ + protected function setUp() + { + if (!class_exists('Symfony\Component\HttpFoundation\Request')) { + $this->markTestSkipped('The "HttpFoundation" component is not available'); + } + } + + 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/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php index e1679d977ee9..c6efa91b768d 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php @@ -16,6 +16,9 @@ use Symfony\Component\EventDispatcher\Event; use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher; use Symfony\Component\HttpKernel\HttpKernel; +use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Stopwatch\Stopwatch; @@ -182,6 +185,43 @@ public function testStopwatchSections() ), 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); + } + protected function getHttpKernel($dispatcher, $controller) { $resolver = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface'); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php index 80d5ffa61a66..61372cd3a0c8 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpKernel\Tests; +namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel; @@ -54,10 +54,25 @@ public function testHandle($type) ->with($this->equalTo('request')) ; $container - ->expects($this->once()) + ->expects($this->at(0)) + ->method('hasScope') + ->with($this->equalTo('request')) + ->will($this->returnValue(false)); + $container + ->expects($this->at(1)) + ->method('addScope') + ->with($this->isInstanceOf('Symfony\Component\DependencyInjection\Scope')); + // enterScope() + $container + ->expects($this->at(3)) ->method('set') ->with($this->equalTo('request'), $this->equalTo($request), $this->equalTo('request')) ; + $container + ->expects($this->at(4)) + ->method('set') + ->with($this->equalTo('request'), $this->equalTo(null), $this->equalTo('request')) + ; $dispatcher = new EventDispatcher(); $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); @@ -101,10 +116,21 @@ public function testHandleRestoresThePreviousRequestOnException($type) ->with($this->equalTo('request')) ; $container - ->expects($this->once()) + ->expects($this->at(0)) + ->method('hasScope') + ->with($this->equalTo('request')) + ->will($this->returnValue(true)); + // enterScope() + $container + ->expects($this->at(2)) ->method('set') ->with($this->equalTo('request'), $this->equalTo($request), $this->equalTo('request')) ; + $container + ->expects($this->at(3)) + ->method('set') + ->with($this->equalTo('request'), $this->equalTo(null), $this->equalTo('request')) + ; $dispatcher = new EventDispatcher(); $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); @@ -126,6 +152,8 @@ public function testHandleRestoresThePreviousRequestOnException($type) try { $kernel->handle($request, $type); $this->fail('->handle() suppresses the controller exception'); + } catch (\PHPUnit_Framework_Exception $exception) { + throw $exception; } catch (\Exception $actual) { $this->assertSame($expected, $actual, '->handle() throws the controller exception'); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php new file mode 100644 index 000000000000..d1e825a8241b --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php @@ -0,0 +1,89 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\HttpKernel\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('getClass') + ->will($this->returnValue('stdClass')); + + $builder = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); + $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('getClass') + ->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\SubscriberService')); + + $builder = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); + $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); + } +} + +class SubscriberService implements \Symfony\Component\EventDispatcher\EventSubscriberInterface +{ + public static function getSubscribedEvents() {} +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php index 9ca64321b2cb..e5e4e3a286df 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php @@ -68,6 +68,17 @@ public function testLocaleSetForRoutingContext() $listener->onKernelRequest($this->getEvent($request)); } + public function testRequestLocaleIsNotOverridden() + { + $request = Request::create('/'); + $request->setLocale('de'); + $listener = new LocaleListener('fr'); + $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/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php index e0a5b0ad5934..cec8ae98403a 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php @@ -17,13 +17,6 @@ class FragmentHandlerTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } - } - /** * @expectedException \InvalidArgumentException */ @@ -61,27 +54,6 @@ public function testRender() $this->assertEquals('foo', $handler->render('/', 'foo', array('foo' => 'foo'))); } - /** - * @dataProvider getFixOptionsData - */ - public function testFixOptions($expected, $options) - { - $handler = new FragmentHandler(); - - set_error_handler(function ($errorNumber, $message, $file, $line, $context) { return $errorNumber & E_USER_DEPRECATED; }); - $this->assertEquals($expected, $handler->fixOptions($options)); - restore_error_handler(); - } - - public function getFixOptionsData() - { - return array( - array(array('strategy' => 'esi'), array('standalone' => true)), - array(array('strategy' => 'esi'), array('standalone' => 'esi')), - array(array('strategy' => 'hinclude'), array('standalone' => 'js')), - ); - } - protected function getHandler($returnValue, $arguments = array()) { $renderer = $this->getMock('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface'); @@ -102,14 +74,7 @@ protected function getHandler($returnValue, $arguments = array()) $handler = new FragmentHandler(); $handler->addRenderer($renderer); - - $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); - $event - ->expects($this->once()) - ->method('getRequest') - ->will($this->returnValue(Request::create('/'))) - ; - $handler->onKernelRequest($event); + $handler->setRequest(Request::create('/')); return $handler; } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php index 1e77374901f0..53baf5ab51f3 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -64,4 +64,19 @@ public function testRenderWhithDefault() $strategy = new HIncludeFragmentRenderer(null, null, 'global_default'); $this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent()); } + + public function testRenderWithAttributesOptions() + { + // with id + $strategy = new HIncludeFragmentRenderer(); + $this->assertEquals('<hx:include src="/foo" id="bar">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'id' => 'bar'))->getContent()); + + // with attributes + $strategy = new HIncludeFragmentRenderer(); + $this->assertEquals('<hx:include src="/foo" p1="v1" p2="v2">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'attributes' => array('p1' => 'v1', 'p2' => 'v2')))->getContent()); + + // with id & attributes + $strategy = new HIncludeFragmentRenderer(); + $this->assertEquals('<hx:include src="/foo" p1="v1" p2="v2" id="bar">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'id' => 'bar', 'attributes' => array('p1' => 'v1', 'p2' => 'v2')))->getContent()); + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php index 380d13a29498..c7ae7dd9aabc 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php @@ -14,6 +14,7 @@ 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; @@ -55,6 +56,8 @@ public function testRenderWithObjectsAsAttributes() '_format' => 'html', '_controller' => 'main_controller', )); + $subRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + $subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); $kernel @@ -73,14 +76,20 @@ public function testRenderWithObjectsAsAttributes() */ public function testRenderExceptionNoIgnoreErrors() { - $strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo')))); + $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() { - $strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo')))); + $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()); } @@ -137,4 +146,25 @@ public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() $this->assertEquals('Foo', ob_get_clean()); } + + public function testESIHeaderIsKeptInSubrequest() + { + $expectedSubRequest = Request::create('/'); + $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); + $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); + + $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel + ->expects($this->any()) + ->method('handle') + ->with($expectedSubRequest) + ; + + $strategy = new InlineFragmentRenderer($kernel); + + $request = Request::create('/'); + $request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); + $strategy->render('/', $request); + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index 4cdd5f60e1f0..a8064b832b7f 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -145,7 +145,7 @@ public function testRespondsWith304WhenIfModifiedSinceMatchesLastModified() $this->assertHttpKernelIsCalled(); $this->assertEquals(304, $this->response->getStatusCode()); - $this->assertEquals('text/html; charset=UTF-8', $this->response->headers->get('Content-Type')); + $this->assertEquals('', $this->response->headers->get('Content-Type')); $this->assertEmpty($this->response->getContent()); $this->assertTraceContains('miss'); $this->assertTraceContains('store'); @@ -158,7 +158,7 @@ public function testRespondsWith304WhenIfNoneMatchMatchesETag() $this->assertHttpKernelIsCalled(); $this->assertEquals(304, $this->response->getStatusCode()); - $this->assertEquals('text/html; charset=UTF-8', $this->response->headers->get('Content-Type')); + $this->assertEquals('', $this->response->headers->get('Content-Type')); $this->assertTrue($this->response->headers->has('ETag')); $this->assertEmpty($this->response->getContent()); $this->assertTraceContains('miss'); @@ -845,7 +845,7 @@ public function testInvalidatesCachedResponsesOnPost() $this->assertTraceContains('fresh'); // now POST to same URL - $this->request('POST', '/'); + $this->request('POST', '/helloworld'); $this->assertHttpKernelIsCalled(); $this->assertEquals('/', $this->response->headers->get('Location')); $this->assertTraceContains('invalidate'); @@ -1075,4 +1075,32 @@ public function testXForwarderForHeaderForPassRequests() $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' => '<esi:include src="/hey" />', + '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/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php index d4295f5ab85b..b36f9093f1b6 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -108,6 +108,52 @@ public function testBootSetsTheBootedFlagToTrue() $this->assertTrue($kernel->isBooted()); } + public function testClassCacheIsLoaded() + { + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') + ->disableOriginalConstructor() + ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles', 'doLoadClassCache')) + ->getMock(); + $kernel->loadClassCache('name', '.extension'); + $kernel->expects($this->any()) + ->method('getBundles') + ->will($this->returnValue(array())); + $kernel->expects($this->once()) + ->method('doLoadClassCache') + ->with('name', '.extension'); + + $kernel->boot(); + } + + public function testClassCacheIsNotLoadedByDefault() + { + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') + ->disableOriginalConstructor() + ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles', 'doLoadClassCache')) + ->getMock(); + $kernel->expects($this->any()) + ->method('getBundles') + ->will($this->returnValue(array())); + $kernel->expects($this->never()) + ->method('doLoadClassCache'); + + $kernel->boot(); + } + + public function testClassCacheIsNotLoadedWhenKernelIsNotBooted() + { + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') + ->disableOriginalConstructor() + ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles', 'doLoadClassCache')) + ->getMock(); + $kernel->loadClassCache(); + $kernel->expects($this->any()) + ->method('getBundles') + ->will($this->returnValue(array())); + $kernel->expects($this->never()) + ->method('doLoadClassCache'); + } + public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce() { $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') @@ -286,7 +332,16 @@ public function doStuff() } EOF; - $this->assertEquals($expected, Kernel::stripComments($source)); + $output = Kernel::stripComments($source); + + // Heredocs are preserved, making the output mixing unix and windows line + // endings, switching to "\n" everywhere on windows to avoid failure. + if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + $expected = str_replace("\r\n", "\n", $expected); + $output = str_replace("\r\n", "\n", $output); + } + + $this->assertEquals($expected, $output); } public function testIsClassInActiveBundleFalse() diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php index 7be88267a585..4657ff1d7648 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php @@ -189,6 +189,21 @@ public function testRetrieveByEmptyUrlAndIp() $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'); @@ -218,7 +233,7 @@ public function testPurge() public function testDuplicates() { for ($i = 1; $i <= 5; $i++) { - $profile = new Profile('foo' . $i); + $profile = new Profile('foo'.$i); $profile->setIp('127.0.0.1'); $profile->setUrl('http://example.net/'); $profile->setMethod('GET'); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php index 21e0bf3df9a2..3c2d04c0d4f1 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php @@ -34,7 +34,7 @@ protected static function cleanDir() public static function setUpBeforeClass() { - self::$tmpDir = sys_get_temp_dir() . '/sf2_profiler_file_storage'; + self::$tmpDir = sys_get_temp_dir().'/sf2_profiler_file_storage'; if (is_dir(self::$tmpDir)) { self::cleanDir(); } @@ -63,9 +63,9 @@ 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); + $profile = new Profile('token'.$i); + $profile->setIp('127.0.0.'.$i); + $profile->setUrl('http://foo.bar/'.$i); $storage = $this->getStorage(); $storage->write($profile); @@ -73,12 +73,12 @@ public function testMultiRowIndexFile() $storage->write($profile); } - $handle = fopen(self::$tmpDir . '/index.csv', 'r'); + $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->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)); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php index 122479b922dd..ca2980edde46 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php @@ -238,17 +238,17 @@ private function storeData($key, $value) return true; } - + public function select($dbnum) { if (!$this->connected) { return false; } - + if (0 > $dbnum) { return false; } - - return true; + + return true; } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json index 1f114f8d4745..6cccbc747b82 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json @@ -18,7 +18,8 @@ "require": { "php": ">=5.3.3", "symfony/event-dispatcher": "~2.1", - "symfony/http-foundation": ">=2.2,<2.3-dev", + "symfony/http-foundation": "~2.2", + "symfony/debug": "~2.3", "psr/log": "~1.0" }, "require-dev": { @@ -29,16 +30,16 @@ "symfony/dependency-injection": "~2.0", "symfony/finder": "~2.0", "symfony/process": "~2.0", - "symfony/routing": ">=2.2,<2.3-dev", - "symfony/stopwatch": ">=2.2,<2.3-dev" + "symfony/routing": "~2.2", + "symfony/stopwatch": "~2.2" }, "suggest": { - "symfony/browser-kit": "2.2.*", - "symfony/class-loader": "2.2.*", - "symfony/config": "2.2.*", - "symfony/console": "2.2.*", - "symfony/dependency-injection": "2.2.*", - "symfony/finder": "2.2.*" + "symfony/browser-kit": "", + "symfony/class-loader": "", + "symfony/config": "", + "symfony/console": "", + "symfony/dependency-injection": "", + "symfony/finder": "" }, "autoload": { "psr-0": { "Symfony\\Component\\HttpKernel\\": "" } @@ -47,7 +48,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/CHANGELOG.md b/core/vendor/symfony/process/Symfony/Component/Process/CHANGELOG.md index 7fa5b72d5027..3bad982fcb12 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/CHANGELOG.md +++ b/core/vendor/symfony/process/Symfony/Component/Process/CHANGELOG.md @@ -1,6 +1,14 @@ CHANGELOG ========= +2.3.0 +----- + + * added ProcessUtils::escapeArgument() to fix the bug in escapeshellarg() function on Windows + * added Process::signal() + * added Process::getPid() + * added support for a TTY mode + 2.2.0 ----- diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Exception/ProcessFailedException.php b/core/vendor/symfony/process/Symfony/Component/Process/Exception/ProcessFailedException.php index 936cbc619cd7..890935933b64 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Exception/ProcessFailedException.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Exception/ProcessFailedException.php @@ -30,8 +30,10 @@ public function __construct(Process $process) parent::__construct( sprintf( - 'The command "%s" failed.'."\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", + 'The command "%s" failed.'."\nExit Code: %s(%s)\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getCommandLine(), + $process->getExitCode(), + $process->getExitCodeText(), $process->getOutput(), $process->getErrorOutput() ) diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Process.php b/core/vendor/symfony/process/Symfony/Component/Process/Process.php index e60373d57b4e..4822e8863ee8 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Process.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Process.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Process; use Symfony\Component\Process\Exception\InvalidArgumentException; +use Symfony\Component\Process\Exception\LogicException; use Symfony\Component\Process\Exception\RuntimeException; /** @@ -35,10 +36,14 @@ class Process const STDOUT = 1; const STDERR = 2; + // Timeout Precision in seconds. + const TIMEOUT_PRECISION = 0.2; + private $commandline; private $cwd; private $env; private $stdin; + private $starttime; private $timeout; private $options; private $exitcode; @@ -53,6 +58,7 @@ class Process private $status = self::STATUS_READY; private $incrementalOutputOffset; private $incrementalErrorOutputOffset; + private $tty; private $fileHandles; private $readBytes; @@ -228,40 +234,13 @@ public function start($callback = null) throw new RuntimeException('Process is already running'); } + $this->starttime = microtime(true); $this->stdout = ''; $this->stderr = ''; $this->incrementalOutputOffset = 0; $this->incrementalErrorOutputOffset = 0; $callback = $this->buildCallback($callback); - - //Fix for PHP bug #51800: reading from STDOUT pipe hangs forever on Windows if the output is too big. - //Workaround for this problem is to use temporary files instead of pipes on Windows platform. - //@see https://bugs.php.net/bug.php?id=51800 - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->fileHandles = array( - self::STDOUT => tmpfile(), - ); - if (false === $this->fileHandles[self::STDOUT]) { - throw new RuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable'); - } - $this->readBytes = array( - self::STDOUT => 0, - ); - $descriptors = array(array('pipe', 'r'), $this->fileHandles[self::STDOUT], array('pipe', 'w')); - } else { - $descriptors = array( - array('pipe', 'r'), // stdin - array('pipe', 'w'), // stdout - array('pipe', 'w'), // stderr - ); - - if ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) { - // last exit code is output on the fourth pipe and caught to work around --enable-sigchild - $descriptors = array_merge($descriptors, array(array('pipe', 'w'))); - - $this->commandline = '('.$this->commandline.') 3>/dev/null; code=$?; echo $code >&3; exit $code'; - } - } + $descriptors = $this->getDescriptors(); $commandline = $this->commandline; @@ -283,6 +262,12 @@ public function start($callback = null) stream_set_blocking($pipe, false); } + + if ($this->tty) { + $this->status = self::STATUS_TERMINATED; + return; + } + if (null === $this->stdin) { fclose($this->pipes[0]); unset($this->pipes[0]); @@ -304,7 +289,7 @@ public function start($callback = null) $w = $writePipes; $e = null; - $n = @stream_select($r, $w, $e, $this->timeout); + $n = @stream_select($r, $w, $e, 0, ceil(static::TIMEOUT_PRECISION * 1E6)); if (false === $n) { break; @@ -337,6 +322,8 @@ public function start($callback = null) unset($this->pipes[$type]); } } + + $this->checkTimeout(); } $this->updateStatus(); @@ -360,7 +347,7 @@ public function start($callback = null) public function restart($callback = null) { if ($this->isRunning()) { - throw new \RuntimeException('Process is already running'); + throw new RuntimeException('Process is already running'); } $process = clone $this; @@ -391,13 +378,15 @@ public function wait($callback = null) if (defined('PHP_WINDOWS_VERSION_BUILD') && $this->fileHandles) { $this->processFileHandles($callback, !$this->pipes); } + $this->checkTimeout(); if ($this->pipes) { $r = $this->pipes; $w = null; $e = null; - if (false === $n = @stream_select($r, $w, $e, $this->timeout)) { + // let's have a look if something changed in streams + if (false === $n = @stream_select($r, $w, $e, 0, ceil(static::TIMEOUT_PRECISION * 1E6))) { $lastError = error_get_last(); // stream_select returns false when the `select` system call is interrupted by an incoming signal @@ -407,10 +396,10 @@ public function wait($callback = null) continue; } - if (0 === $n) { - proc_terminate($this->process); - throw new RuntimeException('The process timed out.'); + // nothing has changed + if (0 === $n) { + continue; } foreach ($r as $pipe) { @@ -434,7 +423,11 @@ public function wait($callback = null) } $this->updateStatus(); if ($this->processInformation['signaled']) { - throw new RuntimeException(sprintf('The process stopped because of a "%s" signal.', $this->processInformation['stopsig'])); + if ($this->isSigchildEnabled()) { + throw new RuntimeException('The process has been signaled.'); + } + + throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig'])); } $time = 0; @@ -446,7 +439,11 @@ public function wait($callback = null) $exitcode = proc_close($this->process); if ($this->processInformation['signaled']) { - throw new RuntimeException(sprintf('The process stopped because of a "%s" signal.', $this->processInformation['stopsig'])); + if ($this->isSigchildEnabled()) { + throw new RuntimeException('The process has been signaled.'); + } + + throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig'])); } $this->exitcode = $this->processInformation['running'] ? $exitcode : $this->processInformation['exitcode']; @@ -458,6 +455,51 @@ public function wait($callback = null) return $this->exitcode; } + /** + * Returns the Pid (process identifier), if applicable. + * + * @return integer|null The process id if running, null otherwise + * + * @throws RuntimeException In case --enable-sigchild is activated + */ + public function getPid() + { + if ($this->isSigchildEnabled()) { + throw new RuntimeException('This PHP has been compiled with --enable-sigchild. The process identifier can not be retrieved.'); + } + + $this->updateStatus(); + + return $this->isRunning() ? $this->processInformation['pid'] : null; + } + + /** + * Sends a posix signal to the process. + * + * @param integer $signal A valid posix signal (see http://www.php.net/manual/en/pcntl.constants.php) + * @return Process + * + * @throws LogicException In case the process is not running + * @throws RuntimeException In case --enable-sigchild is activated + * @throws RuntimeException In case of failure + */ + public function signal($signal) + { + if (!$this->isRunning()) { + throw new LogicException('Can not send signal on a non running process.'); + } + + if ($this->isSigchildEnabled()) { + throw new RuntimeException('This PHP has been compiled with --enable-sigchild. The process can not be signaled.'); + } + + if (true !== @proc_terminate($this->process, $signal)) { + throw new RuntimeException(sprintf('Error while sending signal `%d`.', $signal)); + } + + return $this; + } + /** * Returns the current output of the process (STDOUT). * @@ -705,14 +747,15 @@ public function getStatus() * Stops the process. * * @param integer|float $timeout The timeout in seconds + * @param integer $signal A posix signal to send in case the process has not stop at timeout, default is SIGKILL * * @return integer The exit-code of the process * * @throws RuntimeException if the process got signaled */ - public function stop($timeout = 10) + public function stop($timeout = 10, $signal = null) { - $timeoutMicro = (int) $timeout*10E6; + $timeoutMicro = (int) $timeout*1E6; if ($this->isRunning()) { proc_terminate($this->process); $time = 0; @@ -721,6 +764,12 @@ public function stop($timeout = 10) usleep(1000); } + if ($this->isRunning() && !$this->isSigchildEnabled()) { + if (null !== $signal || defined('SIGKILL')) { + $this->signal($signal ?: SIGKILL); + } + } + foreach ($this->pipes as $pipe) { fclose($pipe); } @@ -800,7 +849,7 @@ public function getTimeout() * * To disable the timeout, set this value to null. * - * @param integer|null $timeout The timeout in seconds + * @param float|null $timeout The timeout in seconds * * @return self The current Process instance * @@ -814,10 +863,10 @@ public function setTimeout($timeout) return $this; } - $timeout = (integer) $timeout; + $timeout = (float) $timeout; if ($timeout < 0) { - throw new InvalidArgumentException('The timeout value must be a valid positive integer.'); + throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.'); } $this->timeout = $timeout; @@ -825,6 +874,30 @@ public function setTimeout($timeout) return $this; } + /** + * Enables or disables the TTY mode. + * + * @param boolean $tty True to enabled and false to disable + * + * @return self The current Process instance + */ + public function setTty($tty) + { + $this->tty = (Boolean) $tty; + + return $this; + } + + /** + * Checks if the TTY mode is enabled. + * + * @return Boolean true if the TTY mode is enabled, false otherwise + */ + public function isTty() + { + return $this->tty; + } + /** * Gets the working directory. * @@ -929,7 +1002,7 @@ public function setOptions(array $options) } /** - * Gets whether or not Windows compatibility is enabled + * Gets whether or not Windows compatibility is enabled. * * This is true by default. * @@ -941,7 +1014,7 @@ public function getEnhanceWindowsCompatibility() } /** - * Sets whether or not Windows compatibility is enabled + * Sets whether or not Windows compatibility is enabled. * * @param Boolean $enhance * @@ -955,7 +1028,7 @@ public function setEnhanceWindowsCompatibility($enhance) } /** - * Return whether sigchild compatibility mode is activated or not + * Returns whether sigchild compatibility mode is activated or not. * * @return Boolean */ @@ -965,7 +1038,7 @@ public function getEnhanceSigchildCompatibility() } /** - * Activate sigchild compatibility mode + * Activates sigchild compatibility mode. * * Sigchild compatibility mode is required to get the exit code and * determine the success of a process when PHP has been compiled with @@ -982,6 +1055,71 @@ public function setEnhanceSigchildCompatibility($enhance) return $this; } + /** + * Performs a check between the timeout definition and the time the process started. + * + * In case you run a background process (with the start method), you should + * trigger this method regularly to ensure the process timeout + * + * @throws RuntimeException In case the timeout was reached + */ + public function checkTimeout() + { + if (0 < $this->timeout && $this->timeout < microtime(true) - $this->starttime) { + $this->stop(0); + + throw new RuntimeException('The process timed-out.'); + } + } + + /** + * Creates the descriptors needed by the proc_open. + * + * @return array + */ + private function getDescriptors() + { + //Fix for PHP bug #51800: reading from STDOUT pipe hangs forever on Windows if the output is too big. + //Workaround for this problem is to use temporary files instead of pipes on Windows platform. + //@see https://bugs.php.net/bug.php?id=51800 + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->fileHandles = array( + self::STDOUT => tmpfile(), + ); + if (false === $this->fileHandles[self::STDOUT]) { + throw new RuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable'); + } + $this->readBytes = array( + self::STDOUT => 0, + ); + + return array(array('pipe', 'r'), $this->fileHandles[self::STDOUT], array('pipe', 'w')); + } + + if ($this->tty) { + $descriptors = array( + array('file', '/dev/tty', 'r'), + array('file', '/dev/tty', 'w'), + array('file', '/dev/tty', 'w'), + ); + } else { + $descriptors = array( + array('pipe', 'r'), // stdin + array('pipe', 'w'), // stdout + array('pipe', 'w'), // stderr + ); + } + + if ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) { + // last exit code is output on the fourth pipe and caught to work around --enable-sigchild + $descriptors = array_merge($descriptors, array(array('pipe', 'w'))); + + $this->commandline = '('.$this->commandline.') 3>/dev/null; code=$?; echo $code >&3; exit $code'; + } + + return $descriptors; + } + /** * Builds up the callback used by wait(). * @@ -1054,7 +1192,7 @@ protected function updateOutput() } /** - * Return whether PHP has been compiled with the '--enable-sigchild' option or not + * Returns whether PHP has been compiled with the '--enable-sigchild' option or not. * * @return Boolean */ @@ -1071,7 +1209,7 @@ protected function isSigchildEnabled() } /** - * Handles the windows file handles fallbacks + * Handles the windows file handles fallbacks. * * @param callable $callback A valid PHP callback * @param Boolean $closeEmptyHandles if true, handles that are empty will be assumed closed diff --git a/core/vendor/symfony/process/Symfony/Component/Process/ProcessBuilder.php b/core/vendor/symfony/process/Symfony/Component/Process/ProcessBuilder.php index 1a95bd0df492..ddd064a2b877 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/ProcessBuilder.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/ProcessBuilder.php @@ -28,6 +28,7 @@ class ProcessBuilder private $timeout; private $options; private $inheritEnv; + private $prefix; public function __construct(array $arguments = array()) { @@ -58,6 +59,22 @@ public function add($argument) return $this; } + /** + * Adds an unescaped prefix to the command string. + * + * The prefix is preserved when reseting arguments. + * + * @param string $prefix A command prefix + * + * @return ProcessBuilder + */ + public function setPrefix($prefix) + { + $this->prefix = $prefix; + + return $this; + } + /** * @param array $arguments * @@ -103,7 +120,7 @@ public function setInput($stdin) * * To disable the timeout, set this value to null. * - * @param integer|null + * @param float|null * * @return ProcessBuilder * @@ -117,10 +134,10 @@ public function setTimeout($timeout) return $this; } - $timeout = (integer) $timeout; + $timeout = (float) $timeout; if ($timeout < 0) { - throw new InvalidArgumentException('The timeout value must be a valid positive integer.'); + throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.'); } $this->timeout = $timeout; @@ -137,13 +154,14 @@ public function setOption($name, $value) public function getProcess() { - if (!count($this->arguments)) { + if (!$this->prefix && !count($this->arguments)) { throw new LogicException('You must add() command arguments before calling getProcess().'); } $options = $this->options; - $script = implode(' ', array_map('escapeshellarg', $this->arguments)); + $arguments = $this->prefix ? array_merge(array($this->prefix), $this->arguments) : $this->arguments; + $script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $arguments)); if ($this->inheritEnv) { $env = $this->env ? $this->env + $_ENV : null; diff --git a/core/vendor/symfony/process/Symfony/Component/Process/ProcessUtils.php b/core/vendor/symfony/process/Symfony/Component/Process/ProcessUtils.php new file mode 100644 index 000000000000..73380be84d4e --- /dev/null +++ b/core/vendor/symfony/process/Symfony/Component/Process/ProcessUtils.php @@ -0,0 +1,60 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Process; + +/** + * ProcessUtils is a bunch of utility methods. + * + * This class contains static methods only and is not meant to be instantiated. + * + * @author Martin Hasoň <martin.hason@gmail.com> + */ +class ProcessUtils +{ + /** + * This class should not be instantiated + */ + private function __construct() + { + } + + /** + * Escapes a string to be used as a shell argument. + * + * @param string $argument The argument that will be escaped + * + * @return string The escaped argument + */ + public static function escapeArgument($argument) + { + //Fix for PHP bug #43784 escapeshellarg removes % from given string + //Fix for PHP bug #49446 escapeshellarg dosn`t work on windows + //@see https://bugs.php.net/bug.php?id=43784 + //@see https://bugs.php.net/bug.php?id=49446 + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $escapedArgument = ''; + foreach(preg_split('/([%"])/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { + if ('"' == $part) { + $escapedArgument .= '\\"'; + } elseif ('%' == $part) { + $escapedArgument .= '^%'; + } else { + $escapedArgument .= escapeshellarg($part); + } + } + + return $escapedArgument; + } + + return escapeshellarg($argument); + } +} diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/AbstractProcessTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/AbstractProcessTest.php index 64798e34c8f4..5cd52efbd9bb 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Process\Tests; use Symfony\Component\Process\Process; +use Symfony\Component\Process\Exception\RuntimeException; /** * @author Robert Schönthal <seroscho@googlemail.com> @@ -44,6 +45,28 @@ public function testNullTimeout() $this->assertNull($p->getTimeout()); } + public function testStopWithTimeoutIsActuallyWorking() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('Stop with timeout does not work on windows, it requires posix signals'); + } + + // exec is mandatory here since we send a signal to the process + // see https://github.com/symfony/symfony/issues/5030 about prepending + // command with exec + $p = $this->getProcess('exec php '.__DIR__.'/NonStopableProcess.php 3'); + $p->start(); + usleep(100000); + $start = microtime(true); + $p->stop(1.1, SIGKILL); + while ($p->isRunning()) { + usleep(1000); + } + $duration = microtime(true) - $start; + + $this->assertLessThan(1.3, $duration); + } + /** * tests results from sub processes * @@ -62,18 +85,21 @@ public function testProcessResponses($expected, $getter, $code) * * @dataProvider pipesCodeProvider */ - public function testProcessPipes($expected, $code) + public function testProcessPipes($code, $size) { if (defined('PHP_WINDOWS_VERSION_BUILD')) { $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 and https://bugs.php.net/bug.php?id=51800'); } + $expected = str_repeat(str_repeat('*', 1024), $size) . '!'; + $expectedLength = (1024 * $size) + 1; + $p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code))); $p->setStdin($expected); $p->run(); - $this->assertSame($expected, $p->getOutput()); - $this->assertSame($expected, $p->getErrorOutput()); + $this->assertEquals($expectedLength, strlen($p->getOutput())); + $this->assertEquals($expectedLength, strlen($p->getErrorOutput())); } public function chainedCommandsOutputProvider() @@ -113,19 +139,19 @@ public function testCallbackIsExecutedForOutput() public function testGetErrorOutput() { - $p = new Process(sprintf('php -r %s', escapeshellarg('ini_set(\'display_errors\',\'on\'); $n = 0; while ($n < 3) { echo $a; $n++; }'))); + $p = new Process(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }'))); $p->run(); - $this->assertEquals(3, preg_match_all('/PHP Notice/', $p->getErrorOutput(), $matches)); + $this->assertEquals(3, preg_match_all('/ERROR/', $p->getErrorOutput(), $matches)); } public function testGetIncrementalErrorOutput() { - $p = new Process(sprintf('php -r %s', escapeshellarg('ini_set(\'display_errors\',\'on\'); usleep(50000); $n = 0; while ($n < 3) { echo $a; $n++; }'))); + $p = new Process(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { usleep(50000); file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }'))); $p->start(); while ($p->isRunning()) { - $this->assertLessThanOrEqual(1, preg_match_all('/PHP Notice/', $p->getIncrementalOutput(), $matches)); + $this->assertLessThanOrEqual(1, preg_match_all('/ERROR/', $p->getIncrementalErrorOutput(), $matches)); usleep(20000); } } @@ -162,6 +188,19 @@ public function testExitCodeCommandFailed() $this->assertGreaterThan(0, $process->getExitCode()); } + public function testTTYCommand() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('Windows does have /dev/tty support'); + } + + $process = $this->getProcess('echo "foo" >> /dev/null'); + $process->setTTY(true); + $process->run(); + + $this->assertSame(Process::STATUS_TERMINATED, $process->getStatus()); + } + public function testExitCodeText() { $process = $this->getProcess(''); @@ -198,7 +237,7 @@ public function testGetExitCode() public function testStatus() { - $process = $this->getProcess('php -r "sleep(1);"'); + $process = $this->getProcess('php -r "usleep(500000);"'); $this->assertFalse($process->isRunning()); $this->assertFalse($process->isStarted()); $this->assertFalse($process->isTerminated()); @@ -251,6 +290,17 @@ public function testProcessIsNotSignaled() $this->assertFalse($process->hasBeenSignaled()); } + public function testProcessWithoutTermSignalIsNotSignaled() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('Windows does not support POSIX signals'); + } + + $process = $this->getProcess('php -m'); + $process->run(); + $this->assertFalse($process->hasBeenSignaled()); + } + public function testProcessWithoutTermSignal() { if (defined('PHP_WINDOWS_VERSION_BUILD')) { @@ -290,6 +340,26 @@ public function testProcessWithTermSignal() $this->assertEquals($termSignal, $process->getTermSignal()); } + public function testProcessThrowsExceptionWhenExternallySignaled() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('Windows does not support POSIX signals'); + } + + if (!function_exists('posix_kill')) { + $this->markTestSkipped('posix_kill is required for this test'); + } + + $termSignal = defined('SIGKILL') ? SIGKILL : 9; + + $process = $this->getProcess('exec php -r "while (true) {}"'); + $process->start(); + posix_kill($process->getPid(), $termSignal); + + $this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'The process has been signaled with signal "9".'); + $process->wait(); + } + public function testRestart() { $process1 = $this->getProcess('php -r "echo getmypid();"'); @@ -320,6 +390,127 @@ public function testPhpDeadlock() // PHP will deadlock when it tries to cleanup $process } + public function testRunProcessWithTimeout() + { + $timeout = 0.5; + $process = $this->getProcess('sleep 3'); + $process->setTimeout($timeout); + $start = microtime(true); + try { + $process->run(); + $this->fail('A RuntimeException should have been raised'); + } catch (RuntimeException $e) { + + } + $duration = microtime(true) - $start; + + $this->assertLessThan($timeout + Process::TIMEOUT_PRECISION, $duration); + } + + public function testCheckTimeoutOnStartedProcess() + { + $timeout = 0.5; + $precision = 100000; + $process = $this->getProcess('sleep 3'); + $process->setTimeout($timeout); + $start = microtime(true); + + $process->start(); + + try { + while ($process->isRunning()) { + $process->checkTimeout(); + usleep($precision); + } + $this->fail('A RuntimeException should have been raised'); + } catch (RuntimeException $e) { + + } + $duration = microtime(true) - $start; + + $this->assertLessThan($timeout + $precision, $duration); + } + + public function testGetPid() + { + $process = $this->getProcess('php -r "sleep(1);"'); + $process->start(); + $this->assertGreaterThan(0, $process->getPid()); + $process->stop(); + } + + public function testGetPidIsNullBeforeStart() + { + $process = $this->getProcess('php -r "sleep(1);"'); + $this->assertNull($process->getPid()); + } + + public function testGetPidIsNullAfterRun() + { + $process = $this->getProcess('php -m'); + $process->run(); + $this->assertNull($process->getPid()); + } + + public function testSignal() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('POSIX signals do not work on windows'); + } + + $process = $this->getProcess('exec php -f ' . __DIR__ . '/SignalListener.php'); + $process->start(); + usleep(500000); + $process->signal(SIGUSR1); + + while ($process->isRunning() && false === strpos($process->getoutput(), 'Caught SIGUSR1')) { + usleep(10000); + } + + $this->assertEquals('Caught SIGUSR1', $process->getOutput()); + } + + /** + * @expectedException Symfony\Component\Process\Exception\LogicException + */ + public function testSignalProcessNotRunning() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('POSIX signals do not work on windows'); + } + + $process = $this->getProcess('php -m'); + $process->signal(SIGHUP); + } + + /** + * @expectedException Symfony\Component\Process\Exception\RuntimeException + */ + public function testSignalWithWrongIntSignal() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('POSIX signals do not work on windows'); + } + + $process = $this->getProcess('php -r "sleep(3);"'); + $process->start(); + $process->signal(-4); + } + + /** + * @expectedException Symfony\Component\Process\Exception\RuntimeException + */ + public function testSignalWithWrongNonIntSignal() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('POSIX signals do not work on windows'); + } + + $process = $this->getProcess('php -r "sleep(3);"'); + $process->start(); + $process->signal('Céphalopodes'); + } + public function responsesCodeProvider() { return array( @@ -334,15 +525,13 @@ public function pipesCodeProvider() { $variations = array( 'fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);', - 'include \'' . __DIR__ . '/ProcessTestHelper.php\';', + 'include \''.__DIR__.'/ProcessTestHelper.php\';', ); - $baseData = str_repeat('*', 1024); $codes = array(); foreach (array(1, 16, 64, 1024, 4096) as $size) { - $data = str_repeat($baseData, $size) . '!'; foreach ($variations as $code) { - $codes[] = array($data, $code); + $codes[] = array($code, $size); } } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/NonStopableProcess.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/NonStopableProcess.php new file mode 100644 index 000000000000..a4db838256af --- /dev/null +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/NonStopableProcess.php @@ -0,0 +1,37 @@ +<?php + +/** + * Runs a PHP script that can be stopped only with a SIGKILL (9) signal for 3 seconds + * + * @args duration Run this script with a custom duration + * + * @example `php NonStopableProcess.php 42` will run the script for 42 seconds + */ + +function handleSignal($signal) +{ + switch ($signal) { + case SIGTERM: + $name = 'SIGTERM'; + break; + case SIGINT: + $name = 'SIGINT'; + break; + default: + $name = $signal . ' (unknown)'; + break; + } + + echo "received signal $name\n"; +} + +declare(ticks=1); +pcntl_signal(SIGTERM, 'handleSignal'); +pcntl_signal(SIGINT, 'handleSignal'); + +$duration = isset($argv[1]) ? (int) $argv[1] : 3; +$start = microtime(true); + +while ($duration > (microtime(true) - $start)) { + usleep(1000); +} diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/PhpProcessTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/PhpProcessTest.php index 7bcdd2f05d9d..df66ad624be3 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/PhpProcessTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/PhpProcessTest.php @@ -1,12 +1,20 @@ <?php +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Process\Tests; use Symfony\Component\Process\PhpProcess; class PhpProcessTest extends \PHPUnit_Framework_TestCase { - public function testNonBlockingWorks() { $expected = 'hello world!'; diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php index 38e14910907e..1f9539689141 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php @@ -15,10 +15,7 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase { - /** - * @test - */ - public function shouldInheritEnvironmentVars() + public function testInheritEnvironmentVars() { $snapshot = $_ENV; $_ENV = $expected = array('foo' => 'bar'); @@ -32,10 +29,7 @@ public function shouldInheritEnvironmentVars() $_ENV = $snapshot; } - /** - * @test - */ - public function shouldInheritAndOverrideEnvironmentVars() + public function testProcessShouldInheritAndOverrideEnvironmentVars() { $snapshot = $_ENV; $_ENV = array('foo' => 'bar', 'bar' => 'baz'); @@ -51,10 +45,7 @@ public function shouldInheritAndOverrideEnvironmentVars() $_ENV = $snapshot; } - /** - * @test - */ - public function shouldInheritEnvironmentVarsByDefault() + public function testInheritEnvironmentVarsByDefault() { $pb = new ProcessBuilder(); $proc = $pb->add('foo')->getProcess(); @@ -62,10 +53,7 @@ public function shouldInheritEnvironmentVarsByDefault() $this->assertNull($proc->getEnv()); } - /** - * @test - */ - public function shouldNotReplaceExplicitlySetVars() + public function testNotReplaceExplicitlySetVars() { $snapshot = $_ENV; $_ENV = array('foo' => 'bar'); @@ -115,4 +103,82 @@ public function testShouldSetArguments() $this->assertContains("second", $proc->getCommandLine()); } + + public function testPrefixIsPrependedToAllGeneratedProcess() + { + $pb = new ProcessBuilder(); + $pb->setPrefix('/usr/bin/php'); + + $proc = $pb->setArguments(array('-v'))->getProcess(); + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->assertEquals('"/usr/bin/php" "-v"', $proc->getCommandLine()); + } else { + $this->assertEquals("'/usr/bin/php' '-v'", $proc->getCommandLine()); + } + + $proc = $pb->setArguments(array('-i'))->getProcess(); + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->assertEquals('"/usr/bin/php" "-i"', $proc->getCommandLine()); + } else { + $this->assertEquals("'/usr/bin/php' '-i'", $proc->getCommandLine()); + } + } + + public function testShouldEscapeArguments() + { + $pb = new ProcessBuilder(array('%path%', 'foo " bar')); + $proc = $pb->getProcess(); + + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->assertSame('^%"path"^% "foo "\\"" bar"', $proc->getCommandLine()); + } else { + $this->assertSame("'%path%' 'foo \" bar'", $proc->getCommandLine()); + } + } + + public function testShouldEscapeArgumentsAndPrefix() + { + $pb = new ProcessBuilder(array('arg')); + $pb->setPrefix('%prefix%'); + $proc = $pb->getProcess(); + + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->assertSame('^%"prefix"^% "arg"', $proc->getCommandLine()); + } else { + $this->assertSame("'%prefix%' 'arg'", $proc->getCommandLine()); + } + } + + /** + * @expectedException \Symfony\Component\Process\Exception\LogicException + */ + public function testShouldThrowALogicExceptionIfNoPrefixAndNoArgument() + { + ProcessBuilder::create()->getProcess(); + } + + public function testShouldNotThrowALogicExceptionIfNoArgument() + { + $process = ProcessBuilder::create() + ->setPrefix('/usr/bin/php') + ->getProcess(); + + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->assertEquals('"/usr/bin/php"', $process->getCommandLine()); + } else { + $this->assertEquals("'/usr/bin/php'", $process->getCommandLine()); + } + } + + public function testShouldNotThrowALogicExceptionIfNoPrefix() + { + $process = ProcessBuilder::create(array('/usr/bin/php')) + ->getProcess(); + + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->assertEquals('"/usr/bin/php"', $process->getCommandLine()); + } else { + $this->assertEquals("'/usr/bin/php'", $process->getCommandLine()); + } + } } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php index 9bc2fdf30fa5..5da55e75ecfd 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php @@ -36,7 +36,8 @@ public function testProcessFailedExceptionThrowsException() '\InvalidArgumentException', 'Expected a failed process, but the given process was successful.' ); - $exception = new ProcessFailedException($process); + + new ProcessFailedException($process); } /** @@ -46,12 +47,14 @@ public function testProcessFailedExceptionThrowsException() public function testProcessFailedExceptionPopulatesInformationFromProcessOutput() { $cmd = 'php'; + $exitCode = 1; + $exitText = 'General error'; $output = "Command output"; $errorOutput = "FATAL: Unexpected error"; $process = $this->getMock( 'Symfony\Component\Process\Process', - array('isSuccessful', 'getOutput', 'getErrorOutput'), + array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText'), array($cmd) ); $process->expects($this->once()) @@ -63,11 +66,17 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput( $process->expects($this->once()) ->method('getErrorOutput') ->will($this->returnValue($errorOutput)); + $process->expects($this->once()) + ->method('getExitCode') + ->will($this->returnValue($exitCode)); + $process->expects($this->once()) + ->method('getExitCodeText') + ->will($this->returnValue($exitText)); $exception = new ProcessFailedException($process); $this->assertEquals( - "The command \"$cmd\" failed.\n\nOutput:\n================\n{$output}\n\nError Output:\n================\n{$errorOutput}", + "The command \"$cmd\" failed.\nExit Code: $exitCode($exitText)\n\nOutput:\n================\n{$output}\n\nError Output:\n================\n{$errorOutput}", $exception->getMessage() ); } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessUtilsTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessUtilsTest.php new file mode 100644 index 000000000000..e51da5a5e22a --- /dev/null +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessUtilsTest.php @@ -0,0 +1,42 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Process\Tests; + +use Symfony\Component\Process\ProcessUtils; + +class ProcessUtilsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider dataArguments + */ + public function testEscapeArgument($result, $argument) + { + $this->assertSame($result, ProcessUtils::escapeArgument($argument)); + } + + public function dataArguments() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + return array( + array('"foo bar"', 'foo bar'), + array('^%"path"^%', '%path%'), + array('"<|>"\\"" "\\""\'f"', '<|>" "\'f'), + ); + } + + return array( + array("'foo bar'", 'foo bar'), + array("'%path%'", '%path%'), + array("'<|>\" \"'\\''f'", '<|>" "\'f'), + ); + } +} diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php index 1e4dc1d0a2f6..2e364d6392b9 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php @@ -64,6 +64,30 @@ public function testProcessWithoutTermSignal() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException */ + public function testGetPid() + { + parent::testGetPid(); + } + + /** + * @expectedException Symfony\Component\Process\Exception\RuntimeException + */ + public function testGetPidIsNullBeforeStart() + { + parent::testGetPidIsNullBeforeStart(); + } + + /** + * @expectedException Symfony\Component\Process\Exception\RuntimeException + */ + public function testGetPidIsNullAfterRun() + { + parent::testGetPidIsNullAfterRun(); + } + + /** + * @expectedException Symfony\Component\Process\Exception\RuntimeException + */ public function testExitCodeText() { $process = $this->getProcess('qdfsmfkqsdfmqmsd'); @@ -88,6 +112,32 @@ public function testIsNotSuccessful() parent::testIsNotSuccessful(); } + /** + * @expectedException Symfony\Component\Process\Exception\RuntimeException + */ + public function testSignal() + { + parent::testSignal(); + } + + /** + * @expectedException Symfony\Component\Process\Exception\RuntimeException + */ + public function testProcessWithoutTermSignalIsNotSignaled() + { + parent::testProcessWithoutTermSignalIsNotSignaled(); + } + + public function testStopWithTimeoutIsActuallyWorking() + { + $this->markTestSkipped('Stopping with signal is not supported in sigchild environment'); + } + + public function testProcessThrowsExceptionWhenExternallySignaled() + { + $this->markTestSkipped('Retrieving Pid is not supported in sigchild environment'); + } + /** * {@inheritdoc} */ diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php index 5c664e24233f..40ffb772b7fb 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php @@ -45,6 +45,30 @@ public function testProcessWithoutTermSignal() parent::testProcessWithoutTermSignal(); } + /** + * @expectedException Symfony\Component\Process\Exception\RuntimeException + */ + public function testGetPid() + { + parent::testGetPid(); + } + + /** + * @expectedException Symfony\Component\Process\Exception\RuntimeException + */ + public function testGetPidIsNullBeforeStart() + { + parent::testGetPidIsNullBeforeStart(); + } + + /** + * @expectedException Symfony\Component\Process\Exception\RuntimeException + */ + public function testGetPidIsNullAfterRun() + { + parent::testGetPidIsNullAfterRun(); + } + public function testExitCodeText() { $process = $this->getProcess('qdfsmfkqsdfmqmsd'); @@ -53,6 +77,27 @@ public function testExitCodeText() $this->assertInternalType('string', $process->getExitCodeText()); } + /** + * @expectedException Symfony\Component\Process\Exception\RuntimeException + */ + public function testSignal() + { + parent::testSignal(); + } + + /** + * @expectedException Symfony\Component\Process\Exception\RuntimeException + */ + public function testProcessWithoutTermSignalIsNotSignaled() + { + parent::testProcessWithoutTermSignalIsNotSignaled(); + } + + public function testProcessThrowsExceptionWhenExternallySignaled() + { + $this->markTestSkipped('Retrieving Pid is not supported in sigchild environment'); + } + /** * {@inheritdoc} */ diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SignalListener.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SignalListener.php new file mode 100644 index 000000000000..8ba167c3317b --- /dev/null +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SignalListener.php @@ -0,0 +1,16 @@ +<?php + +// required for signal handling +declare(ticks = 1); + +pcntl_signal(SIGUSR1, function(){echo "Caught SIGUSR1"; exit;}); + +$n=0; + +// ticks require activity to work - sleep(4); does not work +while($n < 400) { + usleep(10000); + $n++; +} + +return; \ No newline at end of file diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SimpleProcessTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SimpleProcessTest.php index 17dea3fe5403..c5a571888d1e 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SimpleProcessTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SimpleProcessTest.php @@ -79,6 +79,57 @@ public function testIsNotSuccessful() parent::testIsNotSuccessful(); } + public function testGetPid() + { + $this->skipIfPHPSigchild(); + parent::testGetPid(); + } + + public function testGetPidIsNullBeforeStart() + { + $this->skipIfPHPSigchild(); + parent::testGetPidIsNullBeforeStart(); + } + + public function testGetPidIsNullAfterRun() + { + $this->skipIfPHPSigchild(); + parent::testGetPidIsNullAfterRun(); + } + + public function testSignal() + { + $this->skipIfPHPSigchild(); + parent::testSignal(); + } + + /** + * @expectedException Symfony\Component\Process\Exception\LogicException + */ + public function testSignalProcessNotRunning() + { + $this->skipIfPHPSigchild(); + parent::testSignalProcessNotRunning(); + } + + /** + * @expectedException Symfony\Component\Process\Exception\RuntimeException + */ + public function testSignalWithWrongIntSignal() + { + $this->skipIfPHPSigchild(); + parent::testSignalWithWrongIntSignal(); + } + + /** + * @expectedException Symfony\Component\Process\Exception\RuntimeException + */ + public function testSignalWithWrongNonIntSignal() + { + $this->skipIfPHPSigchild(); + parent::testSignalWithWrongNonIntSignal(); + } + /** * {@inheritdoc} */ diff --git a/core/vendor/symfony/process/Symfony/Component/Process/composer.json b/core/vendor/symfony/process/Symfony/Component/Process/composer.json index 1681ef6c1f97..427e63b87fce 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/composer.json +++ b/core/vendor/symfony/process/Symfony/Component/Process/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md b/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md index 873c5f7423d1..f0c616d080b5 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +2.3.0 +----- + + * added RequestContext::getQueryString() + 2.2.0 ----- diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php index 9dac1c1f4cfa..69e3ea832e94 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -196,9 +196,9 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa // 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'; + $url = substr($url, 0, -2).'%2E%2E'; } elseif ('/.' === substr($url, -2)) { - $url = substr($url, 0, -1) . '%2E'; + $url = substr($url, 0, -1).'%2E'; } $schemeAuthority = ''; @@ -309,7 +309,7 @@ public static function getRelativePath($basePath, $targetPath) } $targetDirs[] = $targetFile; - $path = str_repeat('../', count($sourceDirs)) . implode('/', $targetDirs); + $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 diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php index 3919e41ac6d2..da7b33d856ff 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -193,7 +193,7 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, $ */ protected function loadFile($file) { - return XmlUtils::loadFile($file, __DIR__ . static::SCHEME_PATH); + return XmlUtils::loadFile($file, __DIR__.static::SCHEME_PATH); } /** @@ -215,7 +215,12 @@ private function parseConfigs(\DOMElement $node, $path) foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) { switch ($n->localName) { case 'default': - $defaults[$n->getAttribute('key')] = trim($n->textContent); + if ($n->hasAttribute('xsi:nil') && 'true' == $n->getAttribute('xsi:nil')) { + $defaults[$n->getAttribute('key')] = null; + } else { + $defaults[$n->getAttribute('key')] = trim($n->textContent); + } + break; case 'requirement': $requirements[$n->getAttribute('key')] = trim($n->textContent); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php index a3cf2f1c008b..9deea7fe4f55 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -14,7 +14,7 @@ use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Yaml\Yaml; +use Symfony\Component\Yaml\Parser as YamlParser; use Symfony\Component\Config\Loader\FileLoader; /** @@ -30,6 +30,7 @@ class YamlFileLoader extends FileLoader private static $availableKeys = array( 'resource', 'type', 'prefix', 'pattern', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', ); + private $yamlParser; /** * Loads a Yaml file. @@ -47,7 +48,19 @@ public function load($file, $type = null) { $path = $this->locator->locate($file); - $config = Yaml::parse($path); + 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)); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd index ecd852be8aad..daea8143865c 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd @@ -26,7 +26,7 @@ <xsd:group name="configs"> <xsd:choice> - <xsd:element name="default" type="element" /> + <xsd:element name="default" nillable="true" type="element" /> <xsd:element name="requirement" type="element" /> <xsd:element name="option" type="element" /> </xsd:choice> diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php b/core/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php index 132ecc743cee..cb5369689649 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php @@ -29,6 +29,7 @@ class RequestContext private $scheme; private $httpPort; private $httpsPort; + private $queryString; /** * @var array @@ -38,17 +39,18 @@ class RequestContext /** * 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 integer $httpPort The HTTP port - * @param integer $httpsPort The HTTPS port - * @param string $path The path + * @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 integer $httpPort The HTTP port + * @param integer $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 = '/') + public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $scheme = 'http', $httpPort = 80, $httpsPort = 443, $path = '/', $queryString = '') { $this->baseUrl = $baseUrl; $this->method = strtoupper($method); @@ -57,6 +59,7 @@ public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $this->httpPort = $httpPort; $this->httpsPort = $httpsPort; $this->pathInfo = $path; + $this->queryString = $queryString; } public function fromRequest(Request $request) @@ -68,6 +71,7 @@ public function fromRequest(Request $request) $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')); } /** @@ -224,6 +228,28 @@ public function setHttpsPort($httpsPort) $this->httpsPort = $httpsPort; } + /** + * Gets the query string. + * + * @return string The query string + */ + public function getQueryString() + { + return $this->queryString; + } + + /** + * Sets the query string. + * + * @param string $queryString The query string + * + * @api + */ + public function setQueryString($queryString) + { + $this->queryString = $queryString; + } + /** * Returns the parameters. * diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php index 478d4e12a062..060e978116c7 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php @@ -171,7 +171,7 @@ 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->path = '/'.ltrim(trim($pattern), '/'); $this->compiled = null; return $this; @@ -358,7 +358,7 @@ public function getOption($name) } /** - * Checks if a an option has been set + * Checks if an option has been set * * @param string $name An option name * diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php b/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php index b60b7f3d2c49..499fe0f04f83 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php @@ -37,18 +37,6 @@ class RouteCollection implements \IteratorAggregate, \Countable */ private $resources = array(); - /** - * @var string - * @deprecated since version 2.2, will be removed in 2.3 - */ - private $prefix = ''; - - /** - * @var RouteCollection|null - * @deprecated since version 2.2, will be removed in 2.3 - */ - private $parent; - public function __clone() { foreach ($this->routes as $name => $route) { @@ -56,41 +44,6 @@ public function __clone() } } - /** - * Gets the parent RouteCollection. - * - * @return RouteCollection|null The parent RouteCollection or null when it's the root - * - * @deprecated since version 2.2, will be removed in 2.3 - */ - public function getParent() - { - trigger_error('getParent() is deprecated since version 2.2 and will be removed in 2.3. There is no substitution ' . - 'because RouteCollection is not tree structure anymore.', E_USER_DEPRECATED); - - return $this->parent; - } - - /** - * Gets the root RouteCollection. - * - * @return RouteCollection The root RouteCollection - * - * @deprecated since version 2.2, will be removed in 2.3 - */ - public function getRoot() - { - trigger_error('getRoot() is deprecated since version 2.2 and will be removed in 2.3. There is no substitution ' . - 'because RouteCollection is not tree structure anymore.', E_USER_DEPRECATED); - - $parent = $this; - while ($parent->getParent()) { - $parent = $parent->getParent(); - } - - return $parent; - } - /** * Gets the current RouteCollection as an Iterator that includes all routes. * @@ -155,21 +108,11 @@ public function get($name) /** * Removes a route or an array of routes by name from the collection * - * For BC it's also removed from the root, which will not be the case in 2.3 - * as the RouteCollection won't be a tree structure. - * * @param string|array $name The route name or an array of route names */ public function remove($name) { - // just for BC - $root = $this; - while ($root->parent) { - $root = $root->parent; - } - foreach ((array) $name as $n) { - unset($root->routes[$n]); unset($this->routes[$n]); } } @@ -184,34 +127,6 @@ public function remove($name) */ public function addCollection(RouteCollection $collection) { - // This is to keep BC for getParent() and getRoot(). It does not prevent - // infinite loops by recursive referencing. But we don't need that logic - // anymore as the tree logic has been deprecated and we are just widening - // the accepted range. - $collection->parent = $this; - - // this is to keep BC - $numargs = func_num_args(); - if ($numargs > 1) { - trigger_error('addCollection() should only be used with a single parameter. The params $prefix, $defaults, $requirements and $options ' . - 'are deprecated since version 2.2 and will be removed in 2.3. Use addPrefix() and addOptions() instead.', E_USER_DEPRECATED); - $collection->addPrefix($this->prefix . func_get_arg(1)); - if ($numargs > 2) { - $collection->addDefaults(func_get_arg(2)); - if ($numargs > 3) { - $collection->addRequirements(func_get_arg(3)); - if ($numargs > 4) { - $collection->addOptions(func_get_arg(4)); - } - } - } - } else { - // the sub-collection must have the prefix of the parent (current instance) prepended because it does not - // necessarily already have it applied (depending on the order RouteCollections are added to each other) - // this will be removed when the BC layer for getPrefix() is removed - $collection->addPrefix($this->prefix); - } - // 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) { @@ -239,41 +154,13 @@ public function addPrefix($prefix, array $defaults = array(), array $requirement return; } - // a prefix must start with a single slash and must not end with a slash - $this->prefix = '/' . $prefix . $this->prefix; - - // this is to keep BC - if (func_num_args() > 3) { - trigger_error('The fourth parameter ($options) of addPrefix() is deprecated since version 2.2 and will be removed in 2.3. ' . - 'Use addOptions() instead.', E_USER_DEPRECATED); - $options = func_get_arg(3); - } else { - $options = array(); - } - foreach ($this->routes as $route) { - $route->setPath('/' . $prefix . $route->getPath()); + $route->setPath('/'.$prefix.$route->getPath()); $route->addDefaults($defaults); $route->addRequirements($requirements); - $route->addOptions($options); } } - /** - * Returns the prefix that may contain placeholders. - * - * @return string The prefix - * - * @deprecated since version 2.2, will be removed in 2.3 - */ - public function getPrefix() - { - trigger_error('getPrefix() is deprecated since version 2.2 and will be removed in 2.3. The method suggests that ' . - 'all routes in the collection would have this prefix, which is not necessarily true.', E_USER_DEPRECATED); - - return $this->prefix; - } - /** * Sets the host pattern on all routes. * diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php index fe638792b115..d1e289795c18 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php @@ -125,7 +125,7 @@ public function setOptions(array $options) } if ($invalid) { - throw new \InvalidArgumentException(sprintf('The Router does not support the following options: "%s".', implode('\', \'', $invalid))); + throw new \InvalidArgumentException(sprintf('The Router does not support the following options: "%s".', implode('", "', $invalid))); } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml index b4de9efb1fe6..b9f22347b40c 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml @@ -12,6 +12,7 @@ <route id="blog_show_legacy" pattern="/blog/{slug}" host="{locale}.example.com"> <default key="_controller">MyBundle:Blog:show</default> + <default key="slug" xsi:nil="true" /> <requirement key="_method">GET|POST|put|OpTiOnS</requirement> <requirement key="_scheme">hTTps</requirement> <requirement key="locale">\w+</requirement> diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index 512cbd4e1816..5f8ef491276c 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php @@ -316,8 +316,8 @@ public function testUrlEncoding() $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%2F%28%29%2A%27%22+%2B%2C%3B-._%7E%26%24%3C%3E%7C%7B%7D%25%5C%5E%60%21%3Ffoo%3Dbar%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%2F%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 diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php index 833862e21815..9f038c1611a7 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php @@ -68,6 +68,7 @@ public function testLoadWithNamespacePrefix() $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); $this->assertSame('\w+', $route->getRequirement('slug')); $this->assertSame('en|fr|de', $route->getRequirement('_locale')); + $this->assertSame(null, $route->getDefault('slug')); $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php index 62ca947848c4..54b377272d25 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php @@ -1,5 +1,14 @@ <?php +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Routing\Test\Matcher\Dumper; use Symfony\Component\Routing\Matcher\Dumper\DumperCollection; diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php index 398798a7d28a..7b4565c40375 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php @@ -1,5 +1,14 @@ <?php +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Routing\Tests\Matcher\Dumper; use Symfony\Component\Routing\Route; diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php index 901317663f69..3d78adf9232b 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php @@ -97,7 +97,7 @@ public function testAddCollection() $collection->addCollection($collection1); $collection->add('last', $last = new Route('/last')); - $this->assertSame(array('bar' => $bar, 'foo' => $foo, 'grandchild' => $grandchild, 'last' => $last), $collection->all(), + $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'); } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php index 430cae7c7ccd..d663ae960b3d 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php @@ -167,7 +167,7 @@ public function testRouteWithSameVariableTwice() */ public function testRouteWithNumericVariableName($name) { - $route = new Route('/{'. $name . '}'); + $route = new Route('/{'. $name.'}'); $route->compile(); } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouterTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouterTest.php new file mode 100644 index 000000000000..a3c336e5b775 --- /dev/null +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouterTest.php @@ -0,0 +1,138 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Routing\Tests; + +use Symfony\Component\Routing\Router; + +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') + ); + } +} diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json b/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json index 1846578e1548..9a737c6b0287 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json @@ -19,15 +19,15 @@ "php": ">=5.3.3" }, "require-dev": { - "symfony/config": ">=2.2,<2.3-dev", + "symfony/config": "~2.2", "symfony/yaml": "~2.0", "doctrine/common": "~2.2", "psr/log": "~1.0" }, "suggest": { - "symfony/config": "2.2.*", - "symfony/yaml": "2.2.*", - "doctrine/common": "~2.2" + "symfony/config": "", + "symfony/yaml": "", + "doctrine/common": "" }, "autoload": { "psr-0": { "Symfony\\Component\\Routing\\": "" } @@ -36,7 +36,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/CHANGELOG.md b/core/vendor/symfony/serializer/Symfony/Component/Serializer/CHANGELOG.md index 6ccf5e5c4095..5a332da390bb 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/CHANGELOG.md +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +2.3.0 +----- + + * added `GetSetMethodNormalizer::setCamelizedAttributes` to allow calling + camel cased methods for underscored properties + 2.2.0 ----- diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/DecoderInterface.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/DecoderInterface.php index ffd221fe8d58..9dd336d5f785 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/DecoderInterface.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/DecoderInterface.php @@ -19,18 +19,23 @@ interface DecoderInterface { /** - * Decodes a string into PHP data + * Decodes a string into PHP data. * - * @param scalar $data Data to decode - * @param string $format Format name - * @param array $context options that decoders have access to. + * @param scalar $data Data to decode + * @param string $format Format name + * @param array $context options that decoders have access to. + * + * The format parameter specifies which format the data is in; valid values + * depend on the specific implementation. Authors implementing this interface + * are encouraged to document which formats they support in a non-inherited + * phpdoc comment. * * @return mixed */ public function decode($data, $format, array $context = array()); /** - * Checks whether the serializer can decode from given format + * Checks whether the deserializer can decode from given format. * * @param string $format format name * diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonDecode.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonDecode.php index e7cd9e073da5..ca00aa37194b 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -18,19 +18,37 @@ */ class JsonDecode implements DecoderInterface { + /** + * Specifies if the returned result should be an associative array or a nested stdClass object hierarchy. + * + * @var Boolean + */ private $associative; + + /** + * Specifies the recursion depth. + * + * @var integer + */ private $recursionDepth; + private $lastError = JSON_ERROR_NONE; protected $serializer; + /** + * Constructs a new JsonDecode instance. + * + * @param Boolean $associative True to return the result associative array, false for a nested stdClass hierarchy + * @param integer $depth Specifies the recursion depth + */ public function __construct($associative = false, $depth = 512) { $this->associative = $associative; - $this->recursionDepth = $depth; + $this->recursionDepth = (int)$depth; } /** - * Returns the last decoding error (if any) + * Returns the last decoding error (if any). * * @return integer * @@ -42,12 +60,29 @@ public function getLastError() } /** - * Decodes a JSON string into PHP data + * Decodes data. + * + * @param string $data The encoded JSON string to decode + * @param string $format Must be set to JsonEncoder::FORMAT + * @param array $context An optional set of options for the JSON decoder; see below + * + * The $context array is a simple key=>value array, with the following supported keys: * - * @param string $data JSON - * @param string $format + * json_decode_associative: boolean + * If true, returns the object as associative array. + * If false, returns the object as nested StdClass + * If not specified, this method will use the default set in JsonDecode::__construct + * + * json_decode_recursion_depth: integer + * Specifies the maximum recursion depth + * If not specified, this method will use the default set in JsonDecode::__construct + * + * json_decode_options: integer + * Specifies additional options as per documentation for json_decode. Only supported with PHP 5.4.0 and higher * * @return mixed + * + * @see http://php.net/json_decode json_decode */ public function decode($data, $format, array $context = array()) { @@ -77,9 +112,10 @@ public function supportsDecoding($format) } /** - * Merge the default options of the Json Decoder with the passed context. + * Merges the default options of the Json Decoder with the passed context. * * @param array $context + * * @return array */ private function resolveContext(array $context) diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/XmlEncoder.php index 0c77a16a9ecc..137f2fc3272d 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -341,7 +341,7 @@ private function buildXml($parentNode, $data, $xmlRootNodeName = null) return $this->appendNode($parentNode, $data, 'data'); } - throw new UnexpectedValueException('An unexpected value could not be serialized: '.var_export($data, true)); + throw new UnexpectedValueException(sprintf('An unexpected value could not be serialized: %s', var_export($data, true))); } /** diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php index 63e7a1dea91e..6ba30ac2a745 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -38,6 +38,7 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer implements Normal { protected $callbacks = array(); protected $ignoredAttributes = array(); + protected $camelizedAttributes = array(); /** * Set normalization callbacks @@ -66,6 +67,16 @@ public function setIgnoredAttributes(array $ignoredAttributes) $this->ignoredAttributes = $ignoredAttributes; } + /** + * Set attributes to be camelized on denormalize + * + * @param array $camelizedAttributes + */ + public function setCamelizedAttributes(array $camelizedAttributes) + { + $this->camelizedAttributes = $camelizedAttributes; + } + /** * {@inheritdoc} */ @@ -111,7 +122,7 @@ public function denormalize($data, $class, $format = null, array $context = arra $params = array(); foreach ($constructorParameters as $constructorParameter) { - $paramName = lcfirst($constructorParameter->name); + $paramName = lcfirst($this->formatAttribute($constructorParameter->name)); if (isset($data[$paramName])) { $params[] = $data[$paramName]; @@ -132,7 +143,8 @@ public function denormalize($data, $class, $format = null, array $context = arra } foreach ($data as $attribute => $value) { - $setter = 'set'.$attribute; + $setter = 'set'.$this->formatAttribute($attribute); + if (method_exists($object, $setter)) { $object->$setter($value); } @@ -141,6 +153,27 @@ public function denormalize($data, $class, $format = null, array $context = arra return $object; } + /** + * Format attribute name to access parameters or methods + * As option, if attribute name is found on camelizedAttributes array + * returns attribute name in camelcase format + * + * @param string $attributeName + * @return string + */ + protected function formatAttribute($attributeName) + { + if (in_array($attributeName, $this->camelizedAttributes)) { + return preg_replace_callback( + '/(^|_|\.)+(.)/', function ($match) { + return ('.' === $match[1] ? '_' : '').strtoupper($match[2]); + }, $attributeName + ); + } + + return $attributeName; + } + /** * {@inheritDoc} */ diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php index ab6fd58b5fde..73ae9fa47411 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php @@ -75,7 +75,7 @@ public function __construct(array $normalizers = array(), array $encoders = arra final public function serialize($data, $format, array $context = array()) { if (!$this->supportsEncoding($format)) { - throw new UnexpectedValueException('Serialization for the format '.$format.' is not supported'); + throw new UnexpectedValueException(sprintf('Serialization for the format %s is not supported', $format)); } if ($this->encoder->needsNormalization($format)) { @@ -91,7 +91,7 @@ final public function serialize($data, $format, array $context = array()) final public function deserialize($data, $type, $format, array $context = array()) { if (!$this->supportsDecoding($format)) { - throw new UnexpectedValueException('Deserialization for the format '.$format.' is not supported'); + throw new UnexpectedValueException(sprintf('Deserialization for the format %s is not supported', $format)); } $data = $this->decode($data, $format, $context); @@ -128,7 +128,7 @@ public function normalize($data, $format = null, array $context = array()) return $data; } - throw new UnexpectedValueException('An unexpected value could not be normalized: '.var_export($data, true)); + throw new UnexpectedValueException(sprintf('An unexpected value could not be normalized: %s', var_export($data, true))); } /** @@ -173,9 +173,7 @@ public function supportsDenormalization($data, $type, $format = null) private function getNormalizer($data, $format = null) { foreach ($this->normalizers as $normalizer) { - if ($normalizer instanceof NormalizerInterface - && $normalizer->supportsNormalization($data, $format) - ) { + if ($normalizer instanceof NormalizerInterface && $normalizer->supportsNormalization($data, $format)) { return $normalizer; } } @@ -189,9 +187,7 @@ private function getNormalizer($data, $format = null) private function getDenormalizer($data, $type, $format = null) { foreach ($this->normalizers as $normalizer) { - if ($normalizer instanceof DenormalizerInterface - && $normalizer->supportsDenormalization($data, $type, $format) - ) { + if ($normalizer instanceof DenormalizerInterface && $normalizer->supportsDenormalization($data, $type, $format)) { return $normalizer; } } @@ -239,14 +235,15 @@ private function normalizeObject($object, $format = null, array $context = array } foreach ($this->normalizers as $normalizer) { - if ($normalizer->supportsNormalization($object, $format)) { + if ($normalizer instanceof NormalizerInterface + && $normalizer->supportsNormalization($object, $format)) { $this->normalizerCache[$class][$format] = $normalizer; return $normalizer->normalize($object, $format, $context); } } - throw new UnexpectedValueException('Could not normalize object of type '.$class.', no supporting normalizer found.'); + throw new UnexpectedValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', $class)); } /** @@ -273,14 +270,15 @@ private function denormalizeObject($data, $class, $format = null, array $context } foreach ($this->normalizers as $normalizer) { - if ($normalizer->supportsDenormalization($data, $class, $format)) { + if ($normalizer instanceof DenormalizerInterface + && $normalizer->supportsDenormalization($data, $class, $format)) { $this->denormalizerCache[$class][$format] = $normalizer; return $normalizer->denormalize($data, $class, $format, $context); } } - throw new UnexpectedValueException('Could not denormalize object of type '.$class.', no supporting normalizer found.'); + throw new UnexpectedValueException(sprintf('Could not denormalize object of type %s, no supporting normalizer found.', $class)); } /** diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 063753289401..42846166e453 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -26,8 +26,9 @@ public function testNormalize() $obj = new GetSetDummy; $obj->setFoo('foo'); $obj->setBar('bar'); + $obj->setCamelCase('camelcase'); $this->assertEquals( - array('foo' => 'foo', 'bar' => 'bar', 'fooBar' => 'foobar'), + array('foo' => 'foo', 'bar' => 'bar', 'fooBar' => 'foobar', 'camelCase' => 'camelcase'), $this->normalizer->normalize($obj, 'any') ); } @@ -43,6 +44,39 @@ public function testDenormalize() $this->assertEquals('bar', $obj->getBar()); } + public function testDenormalizeOnCamelCaseFormat() + { + $this->normalizer->setCamelizedAttributes(array('camel_case')); + $obj = $this->normalizer->denormalize( + array('camel_case' => 'camelCase'), + __NAMESPACE__.'\GetSetDummy' + ); + $this->assertEquals('camelCase', $obj->getCamelCase()); + } + + /** + * @dataProvider attributeProvider + */ + public function testFormatAttribute($attribute, $camelizedAttributes, $result) + { + $r = new \ReflectionObject($this->normalizer); + $m = $r->getMethod('formatAttribute'); + $m->setAccessible(true); + + $this->normalizer->setCamelizedAttributes($camelizedAttributes); + $this->assertEquals($m->invoke($this->normalizer, $attribute, $camelizedAttributes), $result); + } + + public function attributeProvider() + { + return array( + array('attribute_test', array('attribute_test'),'AttributeTest'), + array('attribute_test', array('any'),'attribute_test'), + array('attribute', array('attribute'),'Attribute'), + array('attribute', array(), 'attribute'), + ); + } + public function testConstructorDenormalize() { $obj = $this->normalizer->denormalize( @@ -82,7 +116,7 @@ public function testUncallableCallbacks() public function testIgnoredAttributes() { - $this->normalizer->setIgnoredAttributes(array('foo', 'bar')); + $this->normalizer->setIgnoredAttributes(array('foo', 'bar', 'camelCase')); $obj = new GetSetDummy; $obj->setFoo('foo'); @@ -160,6 +194,7 @@ class GetSetDummy { protected $foo; private $bar; + protected $camelCase; public function getFoo() { @@ -183,7 +218,17 @@ public function setBar($bar) public function getFooBar() { - return $this->foo . $this->bar; + return $this->foo.$this->bar; + } + + public function getCamelCase() + { + return $this->camelCase; + } + + public function setCamelCase($camelCase) + { + $this->camelCase = $camelCase; } public function otherMethod() diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php new file mode 100644 index 000000000000..e881ad139761 --- /dev/null +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php @@ -0,0 +1,37 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Serializer\Tests\Normalizer; + +use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; + +/** + * Provides a test Normalizer which only implements the DenormalizerInterface. + * + * @author Lin Clark <lin@lin-clark.com> + */ +class TestDenormalizer implements DenormalizerInterface +{ + /** + * {@inheritdoc} + */ + public function denormalize($data, $class, $format = null, array $context = array()) + { + } + + /** + * {@inheritdoc} + */ + public function supportsDenormalization($data, $type, $format = null) + { + return true; + } +} diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php new file mode 100644 index 000000000000..4c000b3eb44a --- /dev/null +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php @@ -0,0 +1,37 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Serializer\Tests\Normalizer; + +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; + +/** + * Provides a test Normalizer which only implements the NormalizerInterface. + * + * @author Lin Clark <lin@lin-clark.com> + */ +class TestNormalizer implements NormalizerInterface +{ + /** + * {@inheritdoc} + */ + public function normalize($object, $format = null, array $context = array()) + { + } + + /** + * {@inheritdoc} + */ + public function supportsNormalization($data, $format = null) + { + return true; + } +} diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/SerializerTest.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/SerializerTest.php index 6470393b1350..3c189461f28f 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -17,6 +17,8 @@ use Symfony\Component\Serializer\Normalizer\CustomNormalizer; use Symfony\Component\Serializer\Tests\Fixtures\TraversableDummy; use Symfony\Component\Serializer\Tests\Fixtures\NormalizableTraversableDummy; +use Symfony\Component\Serializer\Tests\Normalizer\TestNormalizer; +use Symfony\Component\Serializer\Tests\Normalizer\TestDenormalizer; class SerializerTest extends \PHPUnit_Framework_TestCase { @@ -43,6 +45,15 @@ public function testNormalizeGivesPriorityToInterfaceOverTraversable() $this->assertEquals('{"foo":"normalizedFoo","bar":"normalizedBar"}', $result); } + /** + * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException + */ + public function testNormalizeOnDenormalizer() + { + $this->serializer = new Serializer(array(new TestDenormalizer()), array()); + $this->assertTrue($this->serializer->normalize(new \stdClass, 'json')); + } + /** * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException */ @@ -52,6 +63,16 @@ public function testDenormalizeNoMatch() $this->serializer->denormalize('foo', 'stdClass'); } + /** + * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException + */ + public function testDenormalizeOnNormalizer() + { + $this->serializer = new Serializer(array(new TestNormalizer()), array()); + $data = array('title' => 'foo', 'numbers' => array(5, 3)); + $this->assertTrue($this->serializer->denormalize(json_encode($data), 'stdClass', 'json')); + } + public function testSerialize() { $this->serializer = new Serializer(array(new GetSetMethodNormalizer()), array('json' => new JsonEncoder())); @@ -223,5 +244,4 @@ public function toArray() { return array('title' => $this->title, 'numbers' => $this->numbers); } - } diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/composer.json b/core/vendor/symfony/serializer/Symfony/Component/Serializer/composer.json index cff1e49cfa4f..ab537b295527 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/composer.json +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/CHANGELOG.md b/core/vendor/symfony/validator/Symfony/Component/Validator/CHANGELOG.md index fa26425aefc9..7ab8051c1a92 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/CHANGELOG.md +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/CHANGELOG.md @@ -1,6 +1,15 @@ CHANGELOG ========= +2.3.0 +----- + + * added the ISBN, ISSN, and IBAN validators + * copied the constraints `Optional` and `Required` to the + `Symfony\Component\Validator\Constraints\` namespace and deprecated the original + classes. + * added comparison validators (EqualTo, NotEqualTo, LessThan, LessThanOrEqualTo, GreaterThan, GreaterThanOrEqualTo, IdenticalTo, NotIdenticalTo) + 2.2.0 ----- diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidator.php index 839dcb3e6e3a..fec20a9c2b33 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidator.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Validator; -use Symfony\Component\Validator\Exception\ValidatorException; - /** * Base class for constraint validators * @@ -27,93 +25,11 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface */ protected $context; - /** - * @var string - * - * @deprecated - */ - private $messageTemplate; - - /** - * @var array - * - * @deprecated - */ - private $messageParameters; - /** * {@inheritDoc} */ public function initialize(ExecutionContextInterface $context) { $this->context = $context; - $this->messageTemplate = ''; - $this->messageParameters = array(); - } - - /** - * {@inheritDoc} - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. - */ - public function getMessageTemplate() - { - trigger_error('getMessageTemplate() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); - - return $this->messageTemplate; - } - - /** - * {@inheritDoc} - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. - */ - public function getMessageParameters() - { - trigger_error('getMessageParameters() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); - - return $this->messageParameters; - } - - /** - * Wrapper for $this->context->addViolation() - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. - */ - protected function setMessage($template, array $parameters = array()) - { - trigger_error('setMessage() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); - - $this->messageTemplate = $template; - $this->messageParameters = $parameters; - - if (!$this->context instanceof ExecutionContext) { - throw new ValidatorException('ConstraintValidator::initialize() must be called before setting violation messages'); - } - - $this->context->addViolation($template, $parameters); - } - - /** - * Stub implementation delegating to the deprecated isValid method. - * - * This stub exists for BC and will be dropped in Symfony 2.3. - * - * @see ConstraintValidatorInterface::validate - */ - public function validate($value, Constraint $constraint) - { - trigger_error('isValid() is deprecated since version 2.1 and will be removed in 2.3. Implement validate() instead.', E_USER_DEPRECATED); - - return $this->isValid($value, $constraint); - } - - /** - * BC variant of validate. - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. - */ - protected function isValid($value, Constraint $constraint) - { } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolation.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolation.php index 8f73d50c8541..ca8d525f67da 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolation.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolation.php @@ -104,10 +104,10 @@ public function __toString() } if (!empty($code)) { - $code = ' (code ' . $code . ')'; + $code = ' (code '.$code.')'; } - return $class . $propertyPath . ":\n " . $this->getMessage() . $code; + return $class.$propertyPath.":\n ".$this->getMessage().$code; } /** diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationList.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationList.php index ef5a196d0205..84e0a6316dea 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationList.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationList.php @@ -45,7 +45,7 @@ public function __toString() $string = ''; foreach ($this->violations as $violation) { - $string .= $violation . "\n"; + $string .= $violation."\n"; } return $string; diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Min.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparison.php similarity index 52% rename from core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Min.php rename to core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparison.php index 23477ec4036a..b1d9ec67fe7a 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Min.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparison.php @@ -12,23 +12,29 @@ namespace Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Exception\ConstraintDefinitionException; /** - * @Annotation + * Used for the comparison of values. * - * @api - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. + * @author Daniel Holmes <daniel@danielholmes.org> */ -class Min extends Constraint +abstract class AbstractComparison extends Constraint { - public $message = 'This value should be {{ limit }} or more.'; - public $invalidMessage = 'This value should be a valid number.'; - public $limit; + public $message; + public $value; + /** + * {@inheritDoc} + */ public function __construct($options = null) { - trigger_error('Min is deprecated since version 2.1 and will be removed in 2.3. Use Range instead.', E_USER_DEPRECATED); + if (!isset($options['value'])) { + throw new ConstraintDefinitionException(sprintf( + 'The %s constraint requires the "value" option to be set.', + get_class($this) + )); + } parent::__construct($options); } @@ -38,14 +44,6 @@ public function __construct($options = null) */ public function getDefaultOption() { - return 'limit'; - } - - /** - * {@inheritDoc} - */ - public function getRequiredOptions() - { - return array('limit'); + return 'value'; } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php new file mode 100644 index 000000000000..929283eaebfd --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php @@ -0,0 +1,75 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintValidator; + +/** + * Provides a base class for the validation of property comparisons. + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +abstract class AbstractComparisonValidator extends ConstraintValidator +{ + /** + * {@inheritDoc} + */ + public function validate($value, Constraint $constraint) + { + if (!$this->compareValues($value, $constraint->value, $constraint)) { + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $this->valueToString($constraint->value), + '{{ compared_value }}' => $this->valueToString($constraint->value), + '{{ compared_value_type }}' => $this->valueToType($constraint->value) + )); + } + } + + /** + * Returns a string representation of the type of the value. + * + * @param mixed $value + * + * @return string + */ + private function valueToType($value) + { + return is_object($value) ? get_class($value) : gettype($value); + } + + /** + * Returns a string representation of the value. + * + * @param mixed $value + * + * @return string + */ + private function valueToString($value) + { + if ($value instanceof \DateTime) { + return $value->format('Y-m-d H:i:s'); + } + + return var_export($value, true); + } + + /** + * Compares the two given values to find if their relationship is valid + * + * @param mixed $value1 The first value to compare + * @param mixed $value2 The second value to compare + * + * @return Boolean true if the relationship is valid, false otherwise + */ + abstract protected function compareValues($value1, $value2); +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/All.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/All.php index 612aaf270929..537168625ca0 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/All.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/All.php @@ -17,6 +17,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class All extends Constraint @@ -36,11 +38,11 @@ public function __construct($options = null) foreach ($this->constraints as $constraint) { if (!$constraint instanceof Constraint) { - throw new ConstraintDefinitionException('The value ' . $constraint . ' is not an instance of Constraint in constraint ' . __CLASS__); + throw new ConstraintDefinitionException(sprintf('The value %s is not an instance of Constraint in constraint %s', $constraint, __CLASS__)); } if ($constraint instanceof Valid) { - throw new ConstraintDefinitionException('The constraint Valid cannot be nested inside constraint ' . __CLASS__ . '. You can only declare the Valid constraint directly on a field or method.'); + throw new ConstraintDefinitionException(sprintf('The constraint Valid cannot be nested inside constraint %s. You can only declare the Valid constraint directly on a field or method.', __CLASS__)); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Blank.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Blank.php index b6db62a796bb..509479d5e69d 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Blank.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Blank.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Blank extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Callback.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Callback.php index 4470b7093b2e..e93efa4b9914 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Callback.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Callback.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Callback extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Choice.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Choice.php index 70d6fd4da969..50508aeed2b6 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Choice.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Choice.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Choice extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection.php index b618b41cc0b8..956c14ac483d 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection.php @@ -12,13 +12,15 @@ namespace Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\Constraints\Collection\Required; -use Symfony\Component\Validator\Constraints\Collection\Optional; +use Symfony\Component\Validator\Constraints\Required; +use Symfony\Component\Validator\Constraints\Optional; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Collection extends Constraint @@ -43,7 +45,7 @@ public function __construct($options = null) parent::__construct($options); if (!is_array($this->fields)) { - throw new ConstraintDefinitionException('The option "fields" is expected to be an array in constraint ' . __CLASS__); + throw new ConstraintDefinitionException(sprintf('The option "fields" is expected to be an array in constraint %s', __CLASS__)); } foreach ($this->fields as $fieldName => $field) { @@ -57,11 +59,11 @@ public function __construct($options = null) foreach ($field->constraints as $constraint) { if (!$constraint instanceof Constraint) { - throw new ConstraintDefinitionException('The value ' . $constraint . ' of the field ' . $fieldName . ' is not an instance of Constraint in constraint ' . __CLASS__); + throw new ConstraintDefinitionException(sprintf('The value %s of the field %s is not an instance of Constraint in constraint %s', $constraint, $fieldName, __CLASS__)); } if ($constraint instanceof Valid) { - throw new ConstraintDefinitionException('The constraint Valid cannot be nested inside constraint ' . __CLASS__ . '. You can only declare the Valid constraint directly on a field or method.'); + throw new ConstraintDefinitionException(sprintf('The constraint Valid cannot be nested inside constraint %s. You can only declare the Valid constraint directly on a field or method.', __CLASS__)); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Optional.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Optional.php index 8d4c7746dbb8..904d62e08f28 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Optional.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Optional.php @@ -11,17 +11,16 @@ namespace Symfony\Component\Validator\Constraints\Collection; -use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\Optional as BaseOptional; /** * @Annotation + * + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Deprecated in 2.3, to be removed in 3.0. Use + * {@link \Symfony\Component\Validator\Constraints\Optional} instead. */ -class Optional extends Constraint +class Optional extends BaseOptional { - public $constraints = array(); - - public function getDefaultOption() - { - return 'constraints'; - } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Required.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Required.php index 5dda7434dccb..51af2de09ca8 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Required.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Required.php @@ -11,17 +11,16 @@ namespace Symfony\Component\Validator\Constraints\Collection; -use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\Required as BaseRequired; /** * @Annotation + * + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Deprecated in 2.3, to be removed in 3.0. Use + * {@link \Symfony\Component\Validator\Constraints\Required} instead. */ -class Required extends Constraint +class Required extends BaseRequired { - public $constraints = array(); - - public function getDefaultOption() - { - return 'constraints'; - } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CollectionValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CollectionValidator.php index 9249b705311b..f59afe79ee5f 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CollectionValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CollectionValidator.php @@ -14,7 +14,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; -use Symfony\Component\Validator\Constraints\Collection\Optional; +use Symfony\Component\Validator\Constraints\Optional; /** * @author Bernhard Schussek <bschussek@gmail.com> diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Count.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Count.php index afb0089282f6..4a233c19f6c5 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Count.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Count.php @@ -17,6 +17,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Count extends Constraint @@ -39,7 +41,7 @@ public function __construct($options = null) parent::__construct($options); if (null === $this->min && null === $this->max) { - throw new MissingOptionsException('Either option "min" or "max" must be given for constraint ' . __CLASS__, array('min', 'max')); + throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s', __CLASS__), array('min', 'max')); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Country.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Country.php index 5e81df453454..81fa7e05fd85 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Country.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Country.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Country extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CountryValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CountryValidator.php index 1d4995496457..1b3f8653e4ad 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CountryValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CountryValidator.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Constraints; +use Symfony\Component\Intl\Intl; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; @@ -38,8 +39,9 @@ public function validate($value, Constraint $constraint) } $value = (string) $value; + $countries = Intl::getRegionBundle()->getCountryNames(); - if (!in_array($value, \Symfony\Component\Locale\Locale::getCountries())) { + if (!isset($countries[$value])) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Currency.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Currency.php new file mode 100644 index 000000000000..b3bfc8f68b70 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Currency.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; + +/** + * @Annotation + * + * @author Miha Vrhovnik <miha.vrhovnik@pagein.si> + * + * @api + */ +class Currency extends Constraint +{ + public $message = 'This value is not a valid currency.'; +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CurrencyValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CurrencyValidator.php new file mode 100644 index 000000000000..4465e46dfeec --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CurrencyValidator.php @@ -0,0 +1,48 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Intl\Intl; +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; + +/** + * Validates whether a value is a valid currency + * + * @author Miha Vrhovnik <miha.vrhovnik@pagein.si> + * + * @api + */ +class CurrencyValidator extends ConstraintValidator +{ + /** + * {@inheritDoc} + */ + public function validate($value, Constraint $constraint) + { + if (null === $value || '' === $value) { + return; + } + + if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { + throw new UnexpectedTypeException($value, 'string'); + } + + $value = (string) $value; + $currencies = Intl::getCurrencyBundle()->getCurrencyNames(); + + if (!isset($currencies[$value])) { + $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + } + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Date.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Date.php index c34851e28661..f9923052e0cf 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Date.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Date.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Date extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateTime.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateTime.php index a2059b03e9e8..0618bc9b9992 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateTime.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateTime.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class DateTime extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Email.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Email.php index db250dfc4d3a..581dfb985f72 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Email.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Email.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Email extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualTo.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualTo.php new file mode 100644 index 000000000000..3ae29a89fd20 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualTo.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * @Annotation + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class EqualTo extends AbstractComparison +{ + public $message = 'This value should be equal to {{ compared_value }}.'; +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualToValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualToValidator.php new file mode 100644 index 000000000000..2919f1363351 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualToValidator.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * Validates values are equal (==). + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class EqualToValidator extends AbstractComparisonValidator +{ + /** + * @inheritDoc + */ + protected function compareValues($value1, $value2) + { + return $value1 == $value2; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Existence.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Existence.php new file mode 100644 index 000000000000..dbe122b77adc --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Existence.php @@ -0,0 +1,27 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; + +/** + * @author Bernhard Schussek <bschussek@gmail.com> + */ +abstract class Existence extends Constraint +{ + public $constraints = array(); + + public function getDefaultOption() + { + return 'constraints'; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/False.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/False.php index 1a1f1636f30b..fec54456fba0 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/False.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/False.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class False extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/File.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/File.php index 49880ad6790d..9144c6047263 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/File.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/File.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class File extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThan.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThan.php new file mode 100644 index 000000000000..df911256604e --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThan.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * @Annotation + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class GreaterThan extends AbstractComparison +{ + public $message = 'This value should be greater than {{ compared_value }}.'; +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php new file mode 100644 index 000000000000..782893a04d51 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * @Annotation + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class GreaterThanOrEqual extends AbstractComparison +{ + public $message = 'This value should be greater than or equal to {{ compared_value }}.'; +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqualValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqualValidator.php new file mode 100644 index 000000000000..f3b8210a3c39 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqualValidator.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * Validates values are greater than or equal to the previous (>=). + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class GreaterThanOrEqualValidator extends AbstractComparisonValidator +{ + /** + * @inheritDoc + */ + protected function compareValues($value1, $value2) + { + return $value1 >= $value2; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanValidator.php new file mode 100644 index 000000000000..c37ba44ddec4 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanValidator.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * Validates values are greater than the previous (>). + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class GreaterThanValidator extends AbstractComparisonValidator +{ + /** + * @inheritDoc + */ + protected function compareValues($value1, $value2) + { + return $value1 > $value2; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GroupSequence.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GroupSequence.php index c19f5f884853..304fab8c943b 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GroupSequence.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GroupSequence.php @@ -15,6 +15,7 @@ * Annotation for group sequences * * @Annotation + * * @author Bernhard Schussek <bschussek@gmail.com> * * @api diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Iban.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Iban.php new file mode 100644 index 000000000000..b1621959c91c --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Iban.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; + +/** + * @Annotation + */ +class Iban extends Constraint +{ + public $message = 'This is not a valid International Bank Account Number (IBAN).'; +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IbanValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IbanValidator.php new file mode 100644 index 000000000000..fa6f0b559f13 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IbanValidator.php @@ -0,0 +1,62 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintValidator; + +/** + * @author Manuel Reinhard <manu@sprain.ch> + * @author Michael Schummel + * @link http://www.michael-schummel.de/2007/10/05/iban-prufung-mit-php/ + */ +class IbanValidator extends ConstraintValidator +{ + /** + * {@inheritDoc} + */ + public function validate($value, Constraint $constraint) + { + if (null === $value || '' === $value) { + return; + } + + $teststring = preg_replace('/\s+/', '', $value); + + if (strlen($teststring) < 4) { + $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + + return; + } + + $teststring = substr($teststring, 4) + .strval(ord($teststring{0}) - 55) + .strval(ord($teststring{1}) - 55) + .substr($teststring, 2, 2); + + $teststring = preg_replace_callback('/[A-Za-z]/', function ($letter) { + return intval(ord(strtolower($letter[0])) - 87); + }, $teststring); + + $rest = 0; + $strlen = strlen($teststring); + for ($pos = 0; $pos < $strlen; $pos += 7) { + $part = strval($rest).substr($teststring, $pos, 7); + $rest = intval($part) % 97; + } + + if ($rest != 1) { + $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + return; + } + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalTo.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalTo.php new file mode 100644 index 000000000000..f4ae5becc3cf --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalTo.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * @Annotation + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class IdenticalTo extends AbstractComparison +{ + public $message = 'This value should be identical to {{ compared_value_type }} {{ compared_value }}.'; +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalToValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalToValidator.php new file mode 100644 index 000000000000..3d979513e3d2 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalToValidator.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * Validates values are identical (===). + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class IdenticalToValidator extends AbstractComparisonValidator +{ + /** + * @inheritDoc + */ + protected function compareValues($value1, $value2) + { + return $value1 === $value2; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Ip.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Ip.php index 1698d1154cc4..099f2aabd734 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Ip.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Ip.php @@ -18,6 +18,7 @@ * Validates that a value is a valid IP address * * @Annotation + * * @author Bernhard Schussek <bschussek@gmail.com> * @author Joseph Bielawski <stloyd@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Isbn.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Isbn.php new file mode 100644 index 000000000000..4a11e2344852 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Isbn.php @@ -0,0 +1,45 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Exception\MissingOptionsException; + +/** + * @Annotation + * + * @author The Whole Life To Learn <thewholelifetolearn@gmail.com> + */ +class Isbn extends Constraint +{ + public $isbn10Message = 'This value is not a valid ISBN-10.'; + public $isbn13Message = 'This value is not a valid ISBN-13.'; + public $bothIsbnMessage = 'This value is neither a valid ISBN-10 nor a valid ISBN-13.'; + public $isbn10; + public $isbn13; + + public function __construct($options = null) + { + if (null !== $options && !is_array($options)) { + $options = array( + 'isbn10' => $options, + 'isbn13' => $options, + ); + } + + parent::__construct($options); + + if (null === $this->isbn10 && null === $this->isbn13) { + throw new MissingOptionsException(sprintf('Either option "isbn10" or "isbn13" must be given for constraint "%s".', __CLASS__), array('isbn10', 'isbn13')); + } + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IsbnValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IsbnValidator.php new file mode 100644 index 000000000000..62a3b0388e3b --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IsbnValidator.php @@ -0,0 +1,89 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; + +/** + * Validates whether the value is a valid ISBN-10 or ISBN-13. + * + * @author The Whole Life To Learn <thewholelifetolearn@gmail.com> + * + * @see https://en.wikipedia.org/wiki/Isbn + */ +class IsbnValidator extends ConstraintValidator +{ + /** + * {@inheritDoc} + */ + public function validate($value, Constraint $constraint) + { + if (null === $value || '' === $value) { + return; + } + + if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { + throw new UnexpectedTypeException($value, 'string'); + } + + if (!is_numeric($value)) { + $value = str_replace('-', '', $value); + } + + $validation = 0; + $value = strtoupper($value); + $valueLength = strlen($value); + + if (10 === $valueLength && null !== $constraint->isbn10) { + for ($i = 0; $i < 10; $i++) { + if ($value[$i] == 'X') { + $validation += 10 * intval(10 - $i); + } else { + $validation += intval($value[$i]) * intval(10 - $i); + } + } + + if ($validation % 11 != 0) { + if (null !== $constraint->isbn13) { + $this->context->addViolation($constraint->bothIsbnMessage); + } else { + $this->context->addViolation($constraint->isbn10Message); + } + } + } elseif (13 === $valueLength && null !== $constraint->isbn13) { + for ($i = 0; $i < 13; $i += 2) { + $validation += intval($value[$i]); + } + for ($i = 1; $i < 12; $i += 2) { + $validation += intval($value[$i]) * 3; + } + + if ($validation % 10 != 0) { + if (null !== $constraint->isbn10) { + $this->context->addViolation($constraint->bothIsbnMessage); + } else { + $this->context->addViolation($constraint->isbn13Message); + } + } + } else { + if (null !== $constraint->isbn10 && null !== $constraint->isbn13) { + $this->context->addViolation($constraint->bothIsbnMessage); + } elseif (null !== $constraint->isbn10) { + $this->context->addViolation($constraint->isbn10Message); + } else { + $this->context->addViolation($constraint->isbn13Message); + } + } + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Issn.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Issn.php new file mode 100644 index 000000000000..d7d77b657146 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Issn.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; + +/** + * @Annotation + * + * @author Antonio J. GarcÃÂa Lagar <aj@garcialagar.es> + */ +class Issn extends Constraint +{ + public $message = 'This value is not a valid ISSN.'; + public $caseSensitive = false; + public $requireHyphen = false; +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IssnValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IssnValidator.php new file mode 100644 index 000000000000..7e0baa876dce --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IssnValidator.php @@ -0,0 +1,62 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; + +/** + * Validates whether the value is a valid ISSN. + * + * @author Antonio J. GarcÃÂa Lagar <aj@garcialagar.es> + * + * @see https://en.wikipedia.org/wiki/Issn + */ +class IssnValidator extends ConstraintValidator +{ + /** + * {@inheritDoc} + */ + public function validate($value, Constraint $constraint) + { + if (null === $value || '' === $value) { + return; + } + + if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { + throw new UnexpectedTypeException($value, 'string'); + } + + // Compose regex pattern + $digitsPattern = $constraint->requireHyphen ? '\d{4}-\d{3}' : '\d{4}-?\d{3}'; + $checksumPattern = $constraint->caseSensitive ? '[\d|X]' : '[\d|X|x]'; + $pattern = "/^".$digitsPattern.$checksumPattern."$/"; + + if (!preg_match($pattern, $value)) { + $this->context->addViolation($constraint->message); + } else { + $digits = str_split(strtoupper(str_replace('-', '', $value))); + + $sum = 0; + for ($i = 8; $i > 1; $i--) { + $sum += $i * (int) array_shift($digits); + } + + $checksum = 'X' == reset($digits) ? 10 : (int) reset($digits); + + if (0 != ($sum + $checksum) % 11) { + $this->context->addViolation($constraint->message); + } + } + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Language.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Language.php index a0a099bac71a..d14bcd922b8d 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Language.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Language.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Language extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LanguageValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LanguageValidator.php index 5aed18a84f62..5c4dbed2980f 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LanguageValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LanguageValidator.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Constraints; +use Symfony\Component\Intl\Intl; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; @@ -38,8 +39,9 @@ public function validate($value, Constraint $constraint) } $value = (string) $value; + $languages = Intl::getLanguageBundle()->getLanguageNames(); - if (!in_array($value, \Symfony\Component\Locale\Locale::getLanguages())) { + if (!isset($languages[$value])) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Length.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Length.php index cc355574ef0a..84c7303e227b 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Length.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Length.php @@ -17,6 +17,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Length extends Constraint @@ -40,7 +42,7 @@ public function __construct($options = null) parent::__construct($options); if (null === $this->min && null === $this->max) { - throw new MissingOptionsException('Either option "min" or "max" must be given for constraint ' . __CLASS__, array('min', 'max')); + throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s', __CLASS__), array('min', 'max')); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThan.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThan.php new file mode 100644 index 000000000000..3d30ba25d3bd --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThan.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * @Annotation + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class LessThan extends AbstractComparison +{ + public $message = 'This value should be less than {{ compared_value }}.'; +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqual.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqual.php new file mode 100644 index 000000000000..5171c359af61 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqual.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * @Annotation + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class LessThanOrEqual extends AbstractComparison +{ + public $message = 'This value should be less than or equal to {{ compared_value }}.'; +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqualValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqualValidator.php new file mode 100644 index 000000000000..46204b41094a --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqualValidator.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * Validates values are less than or equal to the previous (<=). + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class LessThanOrEqualValidator extends AbstractComparisonValidator +{ + /** + * @inheritDoc + */ + protected function compareValues($value1, $value2) + { + return $value1 <= $value2; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanValidator.php new file mode 100644 index 000000000000..3d86ef366a43 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanValidator.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * Validates values are less than the previous (<). + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class LessThanValidator extends AbstractComparisonValidator +{ + /** + * @inheritDoc + */ + protected function compareValues($value1, $value2) + { + return $value1 < $value2; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Locale.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Locale.php index 9a9025e36103..9cdd7880d047 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Locale.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Locale.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Locale extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LocaleValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LocaleValidator.php index 5cacdb4d199c..97c6aed97733 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LocaleValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LocaleValidator.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Constraints; +use Symfony\Component\Intl\Intl; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; @@ -38,8 +39,9 @@ public function validate($value, Constraint $constraint) } $value = (string) $value; + $locales = Intl::getLocaleBundle()->getLocaleNames(); - if (!in_array($value, \Symfony\Component\Locale\Locale::getLocales())) { + if (!isset($locales[$value])) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Max.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Max.php deleted file mode 100644 index 4017bf8302fc..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Max.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Constraints; - -use Symfony\Component\Validator\Constraint; - -/** - * @Annotation - * - * @api - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. - */ -class Max extends Constraint -{ - public $message = 'This value should be {{ limit }} or less.'; - public $invalidMessage = 'This value should be a valid number.'; - public $limit; - - public function __construct($options = null) - { - trigger_error('Max is deprecated since version 2.1 and will be removed in 2.3. Use Range instead.', E_USER_DEPRECATED); - - parent::__construct($options); - } - - /** - * {@inheritDoc} - */ - public function getDefaultOption() - { - return 'limit'; - } - - /** - * {@inheritDoc} - */ - public function getRequiredOptions() - { - return array('limit'); - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MaxLength.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MaxLength.php deleted file mode 100644 index da0ba8641c03..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MaxLength.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Constraints; - -use Symfony\Component\Validator\Constraint; - -/** - * @Annotation - * - * @api - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. - */ -class MaxLength extends Constraint -{ - public $message = 'This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less.'; - public $limit; - public $charset = 'UTF-8'; - - public function __construct($options = null) - { - trigger_error('MaxLength is deprecated since version 2.1 and will be removed in 2.3. Use Length instead.', E_USER_DEPRECATED); - - parent::__construct($options); - } - - /** - * {@inheritDoc} - */ - public function getDefaultOption() - { - return 'limit'; - } - - /** - * {@inheritDoc} - */ - public function getRequiredOptions() - { - return array('limit'); - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MaxLengthValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MaxLengthValidator.php deleted file mode 100644 index 77ed383e6630..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MaxLengthValidator.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Constraints; - -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - -/** - * @author Bernhard Schussek <bschussek@gmail.com> - * - * @api - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. - */ -class MaxLengthValidator extends ConstraintValidator -{ - public function __construct($options = null) - { - trigger_error('MaxLengthValidator is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); - } - - /** - * {@inheritDoc} - */ - public function validate($value, Constraint $constraint) - { - if (null === $value || '' === $value) { - return; - } - - if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { - throw new UnexpectedTypeException($value, 'string'); - } - - $stringValue = (string) $value; - - if (function_exists('grapheme_strlen') && 'UTF-8' === $constraint->charset) { - $length = grapheme_strlen($stringValue); - } elseif (function_exists('mb_strlen')) { - $length = mb_strlen($stringValue, $constraint->charset); - } else { - $length = strlen($stringValue); - } - - if ($length > $constraint->limit) { - $this->context->addViolation($constraint->message, array( - '{{ value }}' => $stringValue, - '{{ limit }}' => $constraint->limit, - ), $value, (int) $constraint->limit); - } - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MaxValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MaxValidator.php deleted file mode 100644 index a35ae6b3aacf..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MaxValidator.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Constraints; - -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; - -/** - * @author Bernhard Schussek <bschussek@gmail.com> - * - * @api - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. - */ -class MaxValidator extends ConstraintValidator -{ - public function __construct($options = null) - { - trigger_error('MaxValidator is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); - } - - /** - * {@inheritDoc} - */ - public function validate($value, Constraint $constraint) - { - if (null === $value || '' === $value) { - return; - } - - if (!is_numeric($value)) { - $this->context->addViolation($constraint->invalidMessage, array( - '{{ value }}' => $value, - '{{ limit }}' => $constraint->limit, - )); - - return; - } - - if ($value > $constraint->limit) { - $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, - '{{ limit }}' => $constraint->limit, - )); - } - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MinLength.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MinLength.php deleted file mode 100644 index 3335af447770..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MinLength.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Constraints; - -use Symfony\Component\Validator\Constraint; - -/** - * @Annotation - * - * @api - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. - */ -class MinLength extends Constraint -{ - public $message = 'This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.'; - public $limit; - public $charset = 'UTF-8'; - - public function __construct($options = null) - { - trigger_error('MinLength is deprecated since version 2.1 and will be removed in 2.3. Use Length instead.', E_USER_DEPRECATED); - - parent::__construct($options); - } - - /** - * {@inheritDoc} - */ - public function getDefaultOption() - { - return 'limit'; - } - - /** - * {@inheritDoc} - */ - public function getRequiredOptions() - { - return array('limit'); - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MinLengthValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MinLengthValidator.php deleted file mode 100644 index 9b7038e4db46..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MinLengthValidator.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Constraints; - -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - -/** - * @author Bernhard Schussek <bschussek@gmail.com> - * - * @api - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. - */ -class MinLengthValidator extends ConstraintValidator -{ - public function __construct($options = null) - { - trigger_error('MinLengthValidator is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); - } - - /** - * {@inheritDoc} - */ - public function validate($value, Constraint $constraint) - { - if (null === $value || '' === $value) { - return; - } - - if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { - throw new UnexpectedTypeException($value, 'string'); - } - - $stringValue = (string) $value; - - if (function_exists('grapheme_strlen') && 'UTF-8' === $constraint->charset) { - $length = grapheme_strlen($stringValue); - } elseif (function_exists('mb_strlen')) { - $length = mb_strlen($stringValue, $constraint->charset); - } else { - $length = strlen($stringValue); - } - - if ($length < $constraint->limit) { - $this->context->addViolation($constraint->message, array( - '{{ value }}' => $stringValue, - '{{ limit }}' => $constraint->limit, - ), $value, (int) $constraint->limit); - } - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MinValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MinValidator.php deleted file mode 100644 index 117342ae0054..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/MinValidator.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Constraints; - -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; - -/** - * @author Bernhard Schussek <bschussek@gmail.com> - * - * @api - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. - */ -class MinValidator extends ConstraintValidator -{ - public function __construct($options = null) - { - trigger_error('MinValidator is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); - } - - /** - * Checks if the passed value is valid. - * - * @param mixed $value The value that should be validated - * @param Constraint $constraint The constraint for the validation - * - * @api - */ - public function validate($value, Constraint $constraint) - { - if (null === $value || '' === $value) { - return; - } - - if (!is_numeric($value)) { - $this->context->addViolation($constraint->invalidMessage, array( - '{{ value }}' => $value, - '{{ limit }}' => $constraint->limit, - )); - - return; - } - - if ($value < $constraint->limit) { - $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, - '{{ limit }}' => $constraint->limit, - )); - } - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlank.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlank.php index c3281ad7151f..4365ca298ae8 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlank.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlank.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class NotBlank extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlankValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlankValidator.php index dd3dbdd8498a..8d3efae0d584 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlankValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlankValidator.php @@ -15,6 +15,8 @@ use Symfony\Component\Validator\ConstraintValidator; /** + * @author Bernhard Schussek <bschussek@gmail.com> + * * @author Bernhard Schussek <bschussek@gmail.com> * * @api diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualTo.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualTo.php new file mode 100644 index 000000000000..c532565978e5 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualTo.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * @Annotation + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class NotEqualTo extends AbstractComparison +{ + public $message = 'This value should not be equal to {{ compared_value }}.'; +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualToValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualToValidator.php new file mode 100644 index 000000000000..6618f31e402f --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualToValidator.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * Validates values are all unequal (!=). + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class NotEqualToValidator extends AbstractComparisonValidator +{ + /** + * @inheritDoc + */ + protected function compareValues($value1, $value2) + { + return $value1 != $value2; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalTo.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalTo.php new file mode 100644 index 000000000000..49da8586bbb5 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalTo.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * @Annotation + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class NotIdenticalTo extends AbstractComparison +{ + public $message = 'This value should not be identical to {{ compared_value_type }} {{ compared_value }}.'; +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalToValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalToValidator.php new file mode 100644 index 000000000000..ffcb8738dfa2 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalToValidator.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * Validates values aren't identical (!==). + * + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class NotIdenticalToValidator extends AbstractComparisonValidator +{ + /** + * @inheritDoc + */ + protected function compareValues($value1, $value2) + { + return $value1 !== $value2; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotNull.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotNull.php index 2608ab3c0fa0..6b1c7c083632 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotNull.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotNull.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class NotNull extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Null.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Null.php index e110bf854936..e0a00221d197 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Null.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Null.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Null extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Optional.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Optional.php new file mode 100644 index 000000000000..3f286e634036 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Optional.php @@ -0,0 +1,21 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * @Annotation + * + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class Optional extends Existence +{ +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Range.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Range.php index a94825e3da1e..e705175521bb 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Range.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Range.php @@ -17,6 +17,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Range extends Constraint @@ -32,7 +34,7 @@ public function __construct($options = null) parent::__construct($options); if (null === $this->min && null === $this->max) { - throw new MissingOptionsException('Either option "min" or "max" must be given for constraint ' . __CLASS__, array('min', 'max')); + throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s', __CLASS__), array('min', 'max')); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Regex.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Regex.php index fb5dcc1a73e8..beec99b1d191 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Regex.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Regex.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Regex extends Constraint @@ -86,9 +88,9 @@ private function getNonDelimitedPattern() $end = empty($matches[4]) ? '.*' : ''; // Unescape the delimiter in pattern - $pattern = str_replace('\\' . $delimiter, $delimiter, $pattern); + $pattern = str_replace('\\'.$delimiter, $delimiter, $pattern); - return $start . $pattern . $end; + return $start.$pattern.$end; } return null; diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Required.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Required.php new file mode 100644 index 000000000000..609fffd84124 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Required.php @@ -0,0 +1,21 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +/** + * @Annotation + * + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class Required extends Existence +{ +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Time.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Time.php index 3ff8a50b18ef..e7982ac6d661 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Time.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Time.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Time extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/True.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/True.php index a5bfc8583223..9e1d994ba22e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/True.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/True.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class True extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Type.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Type.php index 11dec3c98359..cdcc10c91a39 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Type.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Type.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Type extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Url.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Url.php index 4b4e96cdc591..3585e1b0183e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Url.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Url.php @@ -16,6 +16,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Url extends Constraint diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Valid.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Valid.php index 42b413eb8c5d..ab4676d3dfea 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Valid.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Valid.php @@ -17,6 +17,8 @@ /** * @Annotation * + * @author Bernhard Schussek <bschussek@gmail.com> + * * @api */ class Valid extends Constraint @@ -28,7 +30,7 @@ class Valid extends Constraint public function __construct($options = null) { if (is_array($options) && array_key_exists('groups', $options)) { - throw new ConstraintDefinitionException('The option "groups" is not supported by the constraint ' . __CLASS__); + throw new ConstraintDefinitionException(sprintf('The option "groups" is not supported by the constraint %s', __CLASS__)); } parent::__construct($options); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ExecutionContext.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ExecutionContext.php index 4e904d158fc6..31a959187e35 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ExecutionContext.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ExecutionContext.php @@ -112,64 +112,6 @@ public function addViolation($message, array $params = array(), $invalidValue = )); } - /** - * Adds a violation at the validation graph node with the given property - * path. - * - * @param string $propertyPath The property path for the violation. - * @param string $message The error message. - * @param array $params The parameters parsed into the error message. - * @param mixed $invalidValue The invalid, validated value. - * @param integer|null $pluralization The number to use to pluralize of the message. - * @param integer|null $code The violation code. - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. - */ - public function addViolationAtPath($propertyPath, $message, array $params = array(), $invalidValue = null, $pluralization = null, $code = null) - { - trigger_error('addViolationAtPath() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); - - $this->globalContext->getViolations()->add(new ConstraintViolation( - null === $pluralization - ? $this->translator->trans($message, $params, $this->translationDomain) - : $this->translator->transChoice($message, $pluralization, $params, $this->translationDomain), - $message, - $params, - $this->globalContext->getRoot(), - $propertyPath, - // check using func_num_args() to allow passing null values - func_num_args() >= 4 ? $invalidValue : $this->value, - $pluralization, - $code - )); - } - - /** - * Adds a violation at the validation graph node with the given property - * path relative to the current property path. - * - * @param string $subPath The relative property path for the violation. - * @param string $message The error message. - * @param array $params The parameters parsed into the error message. - * @param mixed $invalidValue The invalid, validated value. - * @param integer|null $pluralization The number to use to pluralize of the message. - * @param integer|null $code The violation code. - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. Use the - * method {@link addViolationAt} instead. - */ - public function addViolationAtSubPath($subPath, $message, array $params = array(), $invalidValue = null, $pluralization = null, $code = null) - { - trigger_error('addViolationAtSubPath() is deprecated since version 2.2 and will be removed in 2.3. Use addViolationAt() instead.', E_USER_DEPRECATED); - - if (func_num_args() >= 4) { - $this->addViolationAt($subPath, $message, $params, $invalidValue, $pluralization, $code); - } else { - // Needed in order to make the check for func_num_args() inside work - $this->addViolationAt($subPath, $message, $params); - } - } - /** * {@inheritdoc} */ @@ -212,10 +154,10 @@ public function getRoot() public function getPropertyPath($subPath = '') { if ('' != $subPath && '' !== $this->propertyPath && '[' !== $subPath[0]) { - return $this->propertyPath . '.' . $subPath; + return $this->propertyPath.'.'.$subPath; } - return $this->propertyPath . $subPath; + return $this->propertyPath.$subPath; } /** @@ -312,74 +254,6 @@ public function validateValue($value, $constraints, $subPath = '', $groups = nul } } - /** - * Returns the class name of the current node. - * - * @return string|null The class name or null, if the current node does not - * hold information about a class. - * - * @see getClassName - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. Use - * {@link getClassName} instead. - */ - public function getCurrentClass() - { - trigger_error('getCurrentClass() is deprecated since version 2.2 and will be removed in 2.3. Use getClassName() instead', E_USER_DEPRECATED); - - return $this->getClassName(); - } - - /** - * Returns the property name of the current node. - * - * @return string|null The property name or null, if the current node does - * not hold information about a property. - * - * @see getPropertyName - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. Use - * {@link getClassName} instead. - */ - public function getCurrentProperty() - { - trigger_error('getCurrentProperty() is deprecated since version 2.2 and will be removed in 2.3. Use getClassName() instead', E_USER_DEPRECATED); - - return $this->getPropertyName(); - } - - /** - * Returns the currently validated value. - * - * @return mixed The current value. - * - * @see getValue - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. Use - * {@link getValue} instead. - */ - public function getCurrentValue() - { - trigger_error('getCurrentValue() is deprecated since version 2.2 and will be removed in 2.3. Use getValue() instead', E_USER_DEPRECATED); - - return $this->value; - } - - /** - * Returns the graph walker instance. - * - * @return GraphWalker The graph walker. - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. Use - * {@link validate} and {@link validateValue} instead. - */ - public function getGraphWalker() - { - trigger_error('getGraphWalker() is deprecated since version 2.2 and will be removed in 2.3. Use validate() and validateValue() instead', E_USER_DEPRECATED); - - return $this->globalContext->getVisitor()->getGraphWalker(); - } - /** * {@inheritdoc} */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/GraphWalker.php b/core/vendor/symfony/validator/Symfony/Component/Validator/GraphWalker.php deleted file mode 100644 index ca212489a6af..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/GraphWalker.php +++ /dev/null @@ -1,236 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator; - -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; -use Symfony\Component\Validator\Mapping\ClassMetadata; -use Symfony\Component\Validator\Mapping\MemberMetadata; - -/** - * Responsible for walking over and initializing validation on different - * types of items. - * - * @author Fabien Potencier <fabien@symfony.com> - * @author Bernhard Schussek <bschussek@gmail.com> - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. This class - * has been replaced by {@link ValidationVisitorInterface} and - * {@link MetadataInterface}. - */ -class GraphWalker -{ - /** - * @var ValidationVisitor - */ - private $visitor; - - /** - * @var MetadataFactoryInterface - */ - private $metadataFactory; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var null|string - */ - private $translationDomain; - - /** - * @var array - */ - private $validatedObjects; - - /** - * Creates a new graph walker. - * - * @param ValidationVisitor $visitor - * @param MetadataFactoryInterface $metadataFactory - * @param TranslatorInterface $translator - * @param null|string $translationDomain - * @param array $validatedObjects - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. - */ - public function __construct(ValidationVisitor $visitor, MetadataFactoryInterface $metadataFactory, TranslatorInterface $translator, $translationDomain = null, array &$validatedObjects = array()) - { - trigger_error('GraphWalker is deprecated since version 2.2 and will be removed in 2.3. This class has been replaced by ValidationVisitorInterface and MetadataInterface.', E_USER_DEPRECATED); - - $this->visitor = $visitor; - $this->metadataFactory = $metadataFactory; - $this->translator = $translator; - $this->translationDomain = $translationDomain; - $this->validatedObjects = &$validatedObjects; - } - - /** - * @return ConstraintViolationList - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. - */ - public function getViolations() - { - trigger_error('getViolations() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); - - return $this->visitor->getViolations(); - } - - /** - * Initialize validation on the given object using the given metadata - * instance and validation group. - * - * @param ClassMetadata $metadata - * @param object $object The object to validate - * @param string $group The validator group to use for validation - * @param string $propertyPath - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. - */ - public function walkObject(ClassMetadata $metadata, $object, $group, $propertyPath) - { - trigger_error('walkObject() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); - - $hash = spl_object_hash($object); - - // Exit, if the object is already validated for the current group - if (isset($this->validatedObjects[$hash][$group])) { - return; - } - - // Remember validating this object before starting and possibly - // traversing the object graph - $this->validatedObjects[$hash][$group] = true; - - $metadata->accept($this->visitor, $object, $group, $propertyPath); - } - - protected function walkObjectForGroup(ClassMetadata $metadata, $object, $group, $propertyPath, $propagatedGroup = null) - { - $metadata->accept($this->visitor, $object, $group, $propertyPath, $propagatedGroup); - } - - /** - * Validates a property of a class. - * - * @param Mapping\ClassMetadata $metadata - * @param $property - * @param $object - * @param $group - * @param $propertyPath - * @param null $propagatedGroup - * - * @throws Exception\UnexpectedTypeException - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. - */ - public function walkProperty(ClassMetadata $metadata, $property, $object, $group, $propertyPath, $propagatedGroup = null) - { - trigger_error('walkProperty() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); - - if (!is_object($object)) { - throw new UnexpectedTypeException($object, 'object'); - } - - foreach ($metadata->getMemberMetadatas($property) as $member) { - $member->accept($this->visitor, $member->getValue($object), $group, $propertyPath, $propagatedGroup); - } - } - - /** - * Validates a property of a class against a potential value. - * - * @param Mapping\ClassMetadata $metadata - * @param $property - * @param $value - * @param $group - * @param $propertyPath - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. - */ - public function walkPropertyValue(ClassMetadata $metadata, $property, $value, $group, $propertyPath) - { - trigger_error('walkPropertyValue() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); - - foreach ($metadata->getMemberMetadatas($property) as $member) { - $member->accept($this->visitor, $value, $group, $propertyPath); - } - } - - protected function walkMember(MemberMetadata $metadata, $value, $group, $propertyPath, $propagatedGroup = null) - { - $metadata->accept($this->visitor, $value, $group, $propertyPath, $propagatedGroup); - } - - /** - * Validates an object or an array. - * - * @param $value - * @param $group - * @param $propertyPath - * @param $traverse - * @param bool $deep - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. - */ - public function walkReference($value, $group, $propertyPath, $traverse, $deep = false) - { - trigger_error('walkReference() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); - - $this->visitor->validate($value, $group, $propertyPath, $traverse, $deep); - } - - /** - * Validates a value against a constraint. - * - * @param Constraint $constraint - * @param $value - * @param $group - * @param $propertyPath - * @param null $currentClass - * @param null $currentProperty - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. - */ - public function walkConstraint(Constraint $constraint, $value, $group, $propertyPath, $currentClass = null, $currentProperty = null) - { - trigger_error('walkConstraint() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); - - $metadata = null; - - // BC code to make getCurrentClass() and getCurrentProperty() work when - // called from within this method - if (null !== $currentClass) { - $metadata = $this->metadataFactory->getMetadataFor($currentClass); - - if (null !== $currentProperty && $metadata instanceof PropertyMetadataContainerInterface) { - $metadata = current($metadata->getPropertyMetadata($currentProperty)); - } - } - - $context = new ExecutionContext( - $this->visitor, - $this->translator, - $this->translationDomain, - $metadata, - $value, - $group, - $propertyPath - ); - - $context->validateValue($value, $constraint); - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadata.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadata.php index 6ea9f2f6d957..b7e003ec3da4 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -252,7 +252,7 @@ public function mergeConstraints(ClassMetadata $source) $this->addMemberMetadata($member); - if (!$member->isPrivate()) { + if (!$member->isPrivate($this->name)) { $property = $member->getPropertyName(); if ($member instanceof PropertyMetadata && !isset($this->properties[$property])) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php index c1155b9c6307..77eb8b528f74 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php @@ -21,7 +21,7 @@ * * @author Bernhard Schussek <bschussek@gmail.com> */ -class ClassMetadataFactory implements ClassMetadataFactoryInterface, MetadataFactoryInterface +class ClassMetadataFactory implements MetadataFactoryInterface { /** * The loader for loading the class metadata @@ -49,7 +49,7 @@ public function __construct(LoaderInterface $loader = null, CacheInterface $cach public function getMetadataFor($value) { if (!is_object($value) && !is_string($value)) { - throw new NoSuchMetadataException('Cannot create metadata for non-objects. Got: ' . gettype($value)); + throw new NoSuchMetadataException(sprintf('Cannot create metadata for non-objects. Got: %s', gettype($value))); } $class = ltrim(is_object($value) ? get_class($value) : $value, '\\'); @@ -63,7 +63,7 @@ public function getMetadataFor($value) } if (!class_exists($class) && !interface_exists($class)) { - throw new NoSuchMetadataException('The class or interface "' . $class . '" does not exist.'); + throw new NoSuchMetadataException(sprintf('The class or interface "%s" does not exist.', $class)); } $metadata = new ClassMetadata($class); @@ -109,17 +109,4 @@ public function hasMetadataFor($value) return false; } - - /** - * {@inheritdoc} - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. Use - * {@link getMetadataFor} instead. - */ - public function getClassMetadata($class) - { - trigger_error('getClassMetadata() is deprecated since version 2.2 and will be removed in 2.3. Use getMetadataFor() instead.', E_USER_DEPRECATED); - - return $this->getMetadataFor($class); - } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactoryAdapter.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactoryAdapter.php deleted file mode 100644 index 95c5849d2654..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactoryAdapter.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Mapping; - -use Symfony\Component\Validator\MetadataFactoryInterface; -use Symfony\Component\Validator\Exception\NoSuchMetadataException; - -/** - * An adapter for exposing {@link ClassMetadataFactoryInterface} implementations - * under the new {@link MetadataFactoryInterface}. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -class ClassMetadataFactoryAdapter implements MetadataFactoryInterface -{ - /** - * @var ClassMetadataFactoryInterface - */ - private $innerFactory; - - public function __construct(ClassMetadataFactoryInterface $innerFactory) - { - trigger_error(sprintf('ClassMetadataFactoryInterface is deprecated since version 2.1 and will be removed in 2.3. Implement MetadataFactoryInterface instead on %s.', get_class($innerFactory)), E_USER_DEPRECATED); - - $this->innerFactory = $innerFactory; - } - - /** - * {@inheritdoc} - */ - public function getMetadataFor($value) - { - $class = is_object($value) ? get_class($value) : $value; - $metadata = $this->innerFactory->getClassMetadata($class); - - if (null === $metadata) { - throw new NoSuchMetadataException('No metadata exists for class '. $class); - } - - return $metadata; - } - - /** - * {@inheritdoc} - */ - public function hasMetadataFor($value) - { - $class = is_object($value) ? get_class($value) : $value; - - $return = null !== $this->innerFactory->getClassMetadata($class); - - return $return; - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactoryInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactoryInterface.php deleted file mode 100644 index 42fff5c8588c..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactoryInterface.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Mapping; - -/** - * A factory for {@link ClassMetadata} objects. - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. Implement - * {@link \Symfony\Component\Validator\MetadataFactoryInterface} instead. - */ -interface ClassMetadataFactoryInterface -{ - /** - * Returns metadata for a given class. - * - * @param string $class The class name. - * - * @return ClassMetadata The class metadata instance. - */ - public function getClassMetadata($class); -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/GetterMetadata.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/GetterMetadata.php index d655b46d172a..1e4406246372 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/GetterMetadata.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/GetterMetadata.php @@ -44,14 +44,14 @@ public function __construct($class, $property) */ public function getPropertyValue($object) { - return $this->getReflectionMember()->invoke($object); + return $this->newReflectionMember($object)->invoke($object); } /** * {@inheritDoc} */ - protected function newReflectionMember() + protected function newReflectionMember($objectOrClassName) { - return new \ReflectionMethod($this->getClassName(), $this->getName()); + return new \ReflectionMethod($objectOrClassName, $this->getName()); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php index 57fe2a55f857..9b3757d522f4 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php @@ -12,10 +12,12 @@ namespace Symfony\Component\Validator\Mapping\Loader; use Symfony\Component\Validator\Mapping\ClassMetadata; -use Symfony\Component\Yaml\Yaml; +use Symfony\Component\Yaml\Parser as YamlParser; class YamlFileLoader extends FileLoader { + private $yamlParser; + /** * An array of YAML class descriptions * @@ -29,7 +31,19 @@ class YamlFileLoader extends FileLoader public function loadClassMetadata(ClassMetadata $metadata) { if (null === $this->classes) { - $this->classes = Yaml::parse($this->file); + if (!stream_is_local($this->file)) { + throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $this->file)); + } + + if (!file_exists($this->file)) { + throw new \InvalidArgumentException(sprintf('File "%s" not found.', $this->file)); + } + + if (null === $this->yamlParser) { + $this->yamlParser = new YamlParser(); + } + + $this->classes = $this->yamlParser->parse(file_get_contents($this->file)); // empty file if (null === $this->classes) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/MemberMetadata.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/MemberMetadata.php index ee9c6839ec50..954083acf75f 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/MemberMetadata.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/MemberMetadata.php @@ -26,7 +26,7 @@ abstract class MemberMetadata extends ElementMetadata implements PropertyMetadat public $cascaded = false; public $collectionCascaded = false; public $collectionCascadedDeeply = false; - private $reflMember; + private $reflMember = array(); /** * Constructor. @@ -123,31 +123,37 @@ public function getPropertyName() /** * Returns whether this member is public * + * @param object|string $objectOrClassName The object or the class name + * * @return Boolean */ - public function isPublic() + public function isPublic($objectOrClassName) { - return $this->getReflectionMember()->isPublic(); + return $this->getReflectionMember($objectOrClassName)->isPublic(); } /** * Returns whether this member is protected * + * @param object|string $objectOrClassName The object or the class name + * * @return Boolean */ - public function isProtected() + public function isProtected($objectOrClassName) { - return $this->getReflectionMember()->isProtected(); + return $this->getReflectionMember($objectOrClassName)->isProtected(); } /** * Returns whether this member is private * + * @param object|string $objectOrClassName The object or the class name + * * @return Boolean */ - public function isPrivate() + public function isPrivate($objectOrClassName) { - return $this->getReflectionMember()->isPrivate(); + return $this->getReflectionMember($objectOrClassName)->isPrivate(); } /** @@ -182,41 +188,29 @@ public function isCollectionCascadedDeeply() return $this->collectionCascadedDeeply; } - /** - * Returns the value of this property in the given object - * - * @param object $object The object - * - * @return mixed The property value - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. Use the - * method {@link getPropertyValue} instead. - */ - public function getValue($object) - { - trigger_error('getValue() is deprecated since version 2.2 and will be removed in 2.3. Use getPropertyValue() instead.', E_USER_DEPRECATED); - - return $this->getPropertyValue($object); - } - /** * Returns the Reflection instance of the member * + * @param object|string $objectOrClassName The object or the class name + * * @return object */ - public function getReflectionMember() + public function getReflectionMember($objectOrClassName) { - if (!$this->reflMember) { - $this->reflMember = $this->newReflectionMember(); + $className = is_string($objectOrClassName) ? $objectOrClassName : get_class($objectOrClassName); + if (!isset($this->reflMember[$className])) { + $this->reflMember[$className] = $this->newReflectionMember($objectOrClassName); } - return $this->reflMember; + return $this->reflMember[$className]; } /** * Creates a new Reflection instance for the member * - * @return object + * @param object|string $objectOrClassName The object or the class name + * + * @return mixed Reflection class */ - abstract protected function newReflectionMember(); + abstract protected function newReflectionMember($objectOrClassName); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/PropertyMetadata.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/PropertyMetadata.php index c68968b0d221..468f196f04a8 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/PropertyMetadata.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/PropertyMetadata.php @@ -37,15 +37,20 @@ public function __construct($class, $name) */ public function getPropertyValue($object) { - return $this->getReflectionMember()->getValue($object); + return $this->getReflectionMember($object)->getValue($object); } /** * {@inheritDoc} */ - protected function newReflectionMember() + protected function newReflectionMember($objectOrClassName) { - $member = new \ReflectionProperty($this->getClassName(), $this->getName()); + $class = new \ReflectionClass($objectOrClassName); + while (!$class->hasProperty($this->getName())) { + $class = $class->getParentClass(); + } + + $member = new \ReflectionProperty($class->getName(), $this->getName()); $member->setAccessible(true); return $member; diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/README.md b/core/vendor/symfony/validator/Symfony/Component/Validator/README.md index 27e0977fbd16..70dd99981a71 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/README.md +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/README.md @@ -107,7 +107,7 @@ https://github.com/fabpot/Silex/blob/master/src/Silex/Provider/ValidatorServiceP Documentation: -http://symfony.com/doc/2.2/book/validation.html +http://symfony.com/doc/2.3/book/validation.html JSR-303 Specification: diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ConstraintValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ConstraintValidatorTest.php deleted file mode 100644 index 47f4c11c992e..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ConstraintValidatorTest.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests; - -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; - -class ConstraintValidatorTest_Validator extends ConstraintValidator -{ - private $message; - private $params; - - public function __construct($message, array $params = array()) - { - $this->message = $message; - $this->params = $params; - } - - public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - - public function validate($value, Constraint $constraint) - { - set_error_handler(array($this, "deprecationErrorHandler")); - $this->setMessage($this->message, $this->params); - restore_error_handler(); - } -} - -class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase -{ - public function testSetMessage() - { - $context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $constraint = $this->getMock('Symfony\Component\Validator\Constraint', array(), array(), '', false); - $validator = new ConstraintValidatorTest_Validator('error message', array('foo' => 'bar')); - $validator->initialize($context); - - $context->expects($this->once()) - ->method('addViolation') - ->with('error message', array('foo' => 'bar')); - - $validator->validate('bam', $constraint); - } - - /** - * @expectedException \Symfony\Component\Validator\Exception\ValidatorException - */ - public function testSetMessageFailsIfNoContextSet() - { - $constraint = $this->getMock('Symfony\Component\Validator\Constraint', array(), array(), '', false); - $validator = new ConstraintValidatorTest_Validator('error message', array('foo' => 'bar')); - - $validator->validate('bam', $constraint); - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php new file mode 100644 index 000000000000..d72eaf23fabd --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -0,0 +1,108 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\AbstractComparisonValidator; + +/** + * @author Daniel Holmes <daniel@danielholmes.org> + */ +abstract class AbstractComparisonValidatorTestCase extends \PHPUnit_Framework_TestCase +{ + private $validator; + private $context; + + protected function setUp() + { + $this->validator = $this->createValidator(); + $this->context = $this->getMockBuilder('Symfony\Component\Validator\ExecutionContext') + ->disableOriginalConstructor() + ->getMock(); + $this->validator->initialize($this->context); + } + + /** + * @return AbstractComparisonValidator + */ + abstract protected function createValidator(); + + public function testThrowsConstraintExceptionIfNoValueOrProperty() + { + $this->setExpectedException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + + $comparison = $this->createConstraint(array()); + $this->validator->validate('some value', $comparison); + } + + /** + * @dataProvider provideValidComparisons + * @param mixed $dirtyValue + * @param mixed $comparisonValue + */ + public function testValidComparisonToValue($dirtyValue, $comparisonValue) + { + $this->context->expects($this->never()) + ->method('addViolation'); + + $constraint = $this->createConstraint(array('value' => $comparisonValue)); + + $this->context->expects($this->any()) + ->method('getPropertyPath') + ->will($this->returnValue('property1')); + + $this->validator->validate($dirtyValue, $constraint); + } + + /** + * @return array + */ + abstract public function provideValidComparisons(); + + /** + * @dataProvider provideInvalidComparisons + * @param mixed $dirtyValue + * @param mixed $comparedValue + * @param mixed $comparedValueString + * @param string $comparedValueType + */ + public function testInvalidComparisonToValue($dirtyValue, $comparedValue, $comparedValueString, $comparedValueType) + { + $constraint = $this->createConstraint(array('value' => $comparedValue)); + $constraint->message = 'Constraint Message'; + + $this->context->expects($this->any()) + ->method('getPropertyPath') + ->will($this->returnValue('property1')); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('Constraint Message', array( + '{{ value }}' => $comparedValueString, + '{{ compared_value }}' => $comparedValueString, + '{{ compared_value_type }}' => $comparedValueType + )); + + $this->validator->validate($dirtyValue, $constraint); + } + + /** + * @return array + */ + abstract public function provideInvalidComparisons(); + + /** + * @param array $options Options for the constraint + * @return Constraint + */ + abstract protected function createConstraint(array $options); +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php index a0e121bba988..e7fed4bf7f2a 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php @@ -12,8 +12,8 @@ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraints\Collection; -use Symfony\Component\Validator\Constraints\Collection\Required; -use Symfony\Component\Validator\Constraints\Collection\Optional; +use Symfony\Component\Validator\Constraints\Required; +use Symfony\Component\Validator\Constraints\Optional; use Symfony\Component\Validator\Constraints\Valid; /** diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php index 2593ee91cd19..4a13234b6955 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php @@ -11,11 +11,10 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Component\Validator\ExecutionContext; use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Constraints\NotNull; -use Symfony\Component\Validator\Constraints\Collection\Required; -use Symfony\Component\Validator\Constraints\Collection\Optional; +use Symfony\Component\Validator\Constraints\Required; +use Symfony\Component\Validator\Constraints\Optional; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\CollectionValidator; diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php index ec617447ad99..3eedaa32643f 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php @@ -11,17 +11,18 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Country; use Symfony\Component\Validator\Constraints\CountryValidator; -class CountryValidatorTest extends LocalizedTestCase +class CountryValidatorTest extends \PHPUnit_Framework_TestCase { protected $context; protected $validator; protected function setUp() { - parent::setUp(); + IntlTestHelper::requireIntl($this); $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); $this->validator = new CountryValidator(); @@ -63,10 +64,6 @@ public function testExpectsStringCompatibleType() */ public function testValidCountries($country) { - if (!class_exists('Symfony\Component\Locale\Locale')) { - $this->markTestSkipped('The "Locale" component is not available'); - } - $this->context->expects($this->never()) ->method('addViolation'); @@ -87,10 +84,6 @@ public function getValidCountries() */ public function testInvalidCountries($country) { - if (!class_exists('Symfony\Component\Locale\Locale')) { - $this->markTestSkipped('The "Locale" component is not available'); - } - $constraint = new Country(array( 'message' => 'myMessage' )); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php new file mode 100644 index 000000000000..d2e233ca3798 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php @@ -0,0 +1,109 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Intl\Util\IntlTestHelper; +use Symfony\Component\Validator\Constraints\Currency; +use Symfony\Component\Validator\Constraints\CurrencyValidator; + +class CurrencyValidatorTest extends \PHPUnit_Framework_TestCase +{ + protected $context; + protected $validator; + + protected function setUp() + { + IntlTestHelper::requireIntl($this); + + $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); + $this->validator = new CurrencyValidator(); + $this->validator->initialize($this->context); + } + + protected function tearDown() + { + $this->context = null; + $this->validator = null; + } + + public function testNullIsValid() + { + $this->context->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate(null, new Currency()); + } + + public function testEmptyStringIsValid() + { + $this->context->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate('', new Currency()); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException + */ + public function testExpectsStringCompatibleType() + { + $this->validator->validate(new \stdClass(), new Currency()); + } + + /** + * @dataProvider getValidCurrencies + */ + public function testValidCurrencies($currency) + { + $this->context->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate($currency, new Currency()); + } + + public function getValidCurrencies() + { + return array( + array('EUR'), + array('USD'), + array('SIT'), + array('AUD'), + array('CAD'), + ); + } + + /** + * @dataProvider getInvalidCurrencies + */ + public function testInvalidCurrencies($currency) + { + $constraint = new Currency(array( + 'message' => 'myMessage' + )); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('myMessage', array( + '{{ value }}' => $currency, + )); + + $this->validator->validate($currency, $constraint); + } + + public function getInvalidCurrencies() + { + return array( + array('EN'), + array('foobar'), + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php new file mode 100644 index 000000000000..61189ed780b1 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php @@ -0,0 +1,57 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraints\EqualTo; +use Symfony\Component\Validator\Constraints\EqualToValidator; +use Symfony\Component\Validator\Tests\Constraints\AbstractComparisonValidatorTestCase; + +/** + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class EqualToValidatorTest extends AbstractComparisonValidatorTestCase +{ + protected function createValidator() + { + return new EqualToValidator(); + } + + protected function createConstraint(array $options) + { + return new EqualTo($options); + } + + /** + * {@inheritDoc} + */ + public function provideValidComparisons() + { + return array( + array(3, 3), + array(3, '3'), + array('a', 'a'), + array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01')) + ); + } + + /** + * {@inheritDoc} + */ + public function provideInvalidComparisons() + { + return array( + array(1, 2, '2', 'integer'), + array('22', '333', "'333'", 'string'), + array(new \DateTime('2001-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime') + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index 5cb4e10047a5..0ca98067d324 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -31,7 +31,7 @@ protected function setUp() $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); $this->validator = new FileValidator(); $this->validator->initialize($this->context); - $this->path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'FileValidatorTest'; + $this->path = sys_get_temp_dir().DIRECTORY_SEPARATOR.'FileValidatorTest'; $this->file = fopen($this->path, 'w'); } @@ -82,7 +82,7 @@ public function testValidUploadedfile() $this->context->expects($this->never()) ->method('addViolation'); - $file = new UploadedFile($this->path, 'originalName'); + $file = new UploadedFile($this->path, 'originalName', null, null, null, true); $this->validator->validate($file, new File()); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php new file mode 100644 index 000000000000..71bcd7195492 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php @@ -0,0 +1,58 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraints\GreaterThanOrEqual; +use Symfony\Component\Validator\Constraints\GreaterThanOrEqualValidator; + +/** + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class GreaterThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase +{ + protected function createValidator() + { + return new GreaterThanOrEqualValidator(); + } + + protected function createConstraint(array $options) + { + return new GreaterThanOrEqual($options); + } + + /** + * {@inheritDoc} + */ + public function provideValidComparisons() + { + return array( + array(3, 2), + array(1, 1), + array(new \DateTime('2010/01/01'), new \DateTime('2000/01/01')), + array(new \DateTime('2000/01/01'), new \DateTime('2000/01/01')), + array('a', 'a'), + array('z', 'a'), + ); + } + + /** + * {@inheritDoc} + */ + public function provideInvalidComparisons() + { + return array( + array(1, 2, '2', 'integer'), + array(new \DateTime('2000/01/01'), new \DateTime('2005/01/01'), '2005-01-01 00:00:00', 'DateTime'), + array('b', 'c', "'c'", 'string') + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php new file mode 100644 index 000000000000..a838c58b7c65 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php @@ -0,0 +1,58 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Symfony\Component\Validator\Constraints\GreaterThanValidator; + +/** + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class GreaterThanValidatorTest extends AbstractComparisonValidatorTestCase +{ + protected function createValidator() + { + return new GreaterThanValidator(); + } + + protected function createConstraint(array $options) + { + return new GreaterThan($options); + } + + /** + * {@inheritDoc} + */ + public function provideValidComparisons() + { + return array( + array(2, 1), + array(new \DateTime('2005/01/01'), new \DateTime('2001/01/01')), + array('333', '22') + ); + } + + /** + * {@inheritDoc} + */ + public function provideInvalidComparisons() + { + return array( + array(1, 2, '2', 'integer'), + array(2, 2, '2', 'integer'), + array(new \DateTime('2000/01/01'), new \DateTime('2005/01/01'), '2005-01-01 00:00:00', 'DateTime'), + array(new \DateTime('2000/01/01'), new \DateTime('2000/01/01'), '2000-01-01 00:00:00', 'DateTime'), + array('22', '333', "'333'", 'string'), + array('22', '22', "'22'", 'string') + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php new file mode 100644 index 000000000000..cfd9f2cd8f43 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php @@ -0,0 +1,187 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraints\Iban; +use Symfony\Component\Validator\Constraints\IbanValidator; + +class IbanValidatorTest extends \PHPUnit_Framework_TestCase +{ + protected $context; + protected $validator; + + protected function setUp() + { + $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); + $this->validator = new IbanValidator(); + $this->validator->initialize($this->context); + } + + public function testNullIsValid() + { + $this->context->expects($this->never())->method('addViolation'); + + $this->validator->validate(null, new Iban()); + } + + public function testEmptyStringIsValid() + { + $this->context->expects($this->never())->method('addViolation'); + + $this->validator->validate('', new Iban()); + } + + /** + * @dataProvider getValidIbans + */ + public function testValidIbans($iban) + { + $this->context->expects($this->never())->method('addViolation'); + + $this->validator->validate($iban, new Iban()); + } + + public function getValidIbans() + { + return array( + array('CH93 0076 2011 6238 5295 7'), //Switzerland + array('CH9300762011623852957'), // Switzerland without spaces + + //Country list + //http://www.rbs.co.uk/corporate/international/g0/guide-to-international-business/regulatory-information/iban/iban-example.ashx + + array('AL47 2121 1009 0000 0002 3569 8741'), //Albania + array('AD12 0001 2030 2003 5910 0100'), //Andorra + array('AT61 1904 3002 3457 3201'), //Austria + array('AZ21 NABZ 0000 0000 1370 1000 1944'), //Azerbaijan + array('BH67 BMAG 0000 1299 1234 56'), //Bahrain + array('BE62 5100 0754 7061'), //Belgium + array('BA39 1290 0794 0102 8494'), //Bosnia and Herzegovina + array('BG80 BNBG 9661 1020 3456 78'), //Bulgaria + array('HR12 1001 0051 8630 0016 0'), //Croatia + array('CY17 0020 0128 0000 0012 0052 7600'), //Cyprus + array('CZ65 0800 0000 1920 0014 5399'), //Czech Republic + array('DK50 0040 0440 1162 43'), //Denmark + array('EE38 2200 2210 2014 5685'), //Estonia + array('FO97 5432 0388 8999 44'), //Faroe Islands + array('FI21 1234 5600 0007 85'), //Finland + array('FR14 2004 1010 0505 0001 3M02 606'), //France + array('GE29 NB00 0000 0101 9049 17'), //Georgia + array('DE89 3704 0044 0532 0130 00'), //Germany + array('GI75 NWBK 0000 0000 7099 453'), //Gibraltar + array('GR16 0110 1250 0000 0001 2300 695'), //Greece + array('GL56 0444 9876 5432 10'), //Greenland + array('HU42 1177 3016 1111 1018 0000 0000'), //Hungary + array('IS14 0159 2600 7654 5510 7303 39'), //Iceland + array('IE29 AIBK 9311 5212 3456 78'), //Ireland + array('IL62 0108 0000 0009 9999 999'), //Israel + array('IT40 S054 2811 1010 0000 0123 456'), //Italy + array('LV80 BANK 0000 4351 9500 1'), //Latvia + array('LB62 0999 0000 0001 0019 0122 9114'), //Lebanon + array('LI21 0881 0000 2324 013A A'), //Liechtenstein + array('LT12 1000 0111 0100 1000'), //Lithuania + array('LU28 0019 4006 4475 0000'), //Luxembourg + array('MK072 5012 0000 0589 84'), //Macedonia + array('MT84 MALT 0110 0001 2345 MTLC AST0 01S'), //Malta + array('MU17 BOMM 0101 1010 3030 0200 000M UR'), //Mauritius + array('MD24 AG00 0225 1000 1310 4168'), //Moldova + array('MC93 2005 2222 1001 1223 3M44 555'), //Monaco + array('ME25 5050 0001 2345 6789 51'), //Montenegro + array('NL39 RABO 0300 0652 64'), //Netherlands + array('NO93 8601 1117 947'), //Norway + array('PK36 SCBL 0000 0011 2345 6702'), //Pakistan + array('PL60 1020 1026 0000 0422 7020 1111'), //Poland + array('PT50 0002 0123 1234 5678 9015 4'), //Portugal + array('RO49 AAAA 1B31 0075 9384 0000'), //Romania + array('SM86 U032 2509 8000 0000 0270 100'), //San Marino + array('SA03 8000 0000 6080 1016 7519'), //Saudi Arabia + array('RS35 2600 0560 1001 6113 79'), //Serbia + array('SK31 1200 0000 1987 4263 7541'), //Slovak Republic + array('SI56 1910 0000 0123 438'), //Slovenia + array('ES80 2310 0001 1800 0001 2345'), //Spain + array('SE35 5000 0000 0549 1000 0003'), //Sweden + array('CH93 0076 2011 6238 5295 7'), //Switzerland + array('TN59 1000 6035 1835 9847 8831'), //Tunisia + array('TR33 0006 1005 1978 6457 8413 26'), //Turkey + array('AE07 0331 2345 6789 0123 456'), //UAE + array('GB 12 CPBK 0892 9965 0449 91'), //United Kingdom + + //Extended country list + //http://www.nordea.com/Our+services/International+products+and+services/Cash+Management/IBAN+countries/908462.html + array('AO06000600000100037131174'), //Angola + array('AZ21NABZ00000000137010001944'), //Azerbaijan + array('BH29BMAG1299123456BH00'), //Bahrain + array('BJ11B00610100400271101192591'), //Benin + array('VG96VPVG0000012345678901'), //British Virgin Islands + array('BF1030134020015400945000643'), //Burkina Faso + array('BI43201011067444'), //Burundi + array('CM2110003001000500000605306'), //Cameroon + array('CV64000300004547069110176'), //Cape Verde + array('FR7630007000110009970004942'), //Central African Republic + array('CG5230011000202151234567890'), //Congo + array('CR0515202001026284066'), //Costa Rica + array('DO28BAGR00000001212453611324'), //Dominican Republic + array('GT82TRAJ01020000001210029690'), //Guatemala + array('IR580540105180021273113007'), //Iran + array('IL620108000000099999999'), //Israel + array('CI05A00060174100178530011852'), //Ivory Coast + array('KZ176010251000042993'), //Kazakhstan + array('KW74NBOK0000000000001000372151'), //Kuwait + array('LB30099900000001001925579115'), //Lebanon + array('MG4600005030010101914016056'), //Madagascar + array('ML03D00890170001002120000447'), //Mali + array('MR1300012000010000002037372'), //Mauritania + array('MU17BOMM0101101030300200000MUR'), //Mauritius + array('MZ59000100000011834194157'), //Mozambique + array('PS92PALS000000000400123456702'), //Palestinian Territory + array('PT50000200000163099310355'), //Sao Tome and Principe + array('SA0380000000608010167519'), //Saudi Arabia + array('SN12K00100152000025690007542'), //Senegal + array('TN5914207207100707129648'), //Tunisia + array('TR330006100519786457841326'), //Turkey + array('AE260211000000230064016'), //United Arab Emirates + ); + } + + /** + * @dataProvider getInvalidIbans + */ + public function testInvalidIbans($iban) + { + $constraint = new Iban(array( + 'message' => 'myMessage' + )); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('myMessage', array( + '{{ value }}' => $iban, + )); + + $this->validator->validate($iban, $constraint); + } + + public function getInvalidIbans() + { + return array( + array('CH93 0076 2011 6238 5295'), + array('CH930076201162385295'), + array('GB29 RBOS 6016 1331 9268 19'), + array('CH930072011623852957'), + array('NL39 RASO 0300 0652 64'), + array('NO93 8601117 947'), + array('CY170020 128 0000 0012 0052 7600'), + array('foo'), + array('123'), + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php new file mode 100644 index 000000000000..58fdb7e5895b --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php @@ -0,0 +1,60 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraints\IdenticalTo; +use Symfony\Component\Validator\Constraints\IdenticalToValidator; +use Symfony\Component\Validator\Tests\Constraints\AbstractComparisonValidatorTestCase; + +/** + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase +{ + protected function createValidator() + { + return new IdenticalToValidator(); + } + + protected function createConstraint(array $options) + { + return new IdenticalTo($options); + } + + /** + * {@inheritDoc} + */ + public function provideValidComparisons() + { + $date = new \DateTime('2000-01-01'); + + return array( + array(3, 3), + array('a', 'a'), + array($date, $date) + ); + } + + /** + * {@inheritDoc} + */ + public function provideInvalidComparisons() + { + return array( + array(1, 2, '2', 'integer'), + array(2, '2', "'2'", 'string'), + array('22', '333', "'333'", 'string'), + array(new \DateTime('2001-01-01'), new \DateTime('2001-01-01'), '2001-01-01 00:00:00', 'DateTime'), + array(new \DateTime('2001-01-01'), new \DateTime('1999-01-01'), '1999-01-01 00:00:00', 'DateTime') + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php new file mode 100644 index 000000000000..dceb86cf3d96 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php @@ -0,0 +1,223 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraints\Isbn; +use Symfony\Component\Validator\Constraints\IsbnValidator; + +/** + * @see https://en.wikipedia.org/wiki/Isbn + */ +class IsbnValidatorTest extends \PHPUnit_Framework_TestCase +{ + protected $context; + protected $validator; + + public function setUp() + { + $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); + $this->validator = new IsbnValidator(); + $this->validator->initialize($this->context); + } + + public function getValidIsbn10() + { + return array( + array('2723442284'), + array('2723442276'), + array('2723455041'), + array('2070546810'), + array('2711858839'), + array('2756406767'), + array('2870971648'), + array('226623854X'), + array('2851806424'), + array('0321812700'), + array('0-45122-5244'), + array('0-4712-92311'), + ); + } + + public function getInvalidIsbn10() + { + return array( + array('1234567890'), + array('987'), + array('0987656789'), + array(0), + array('7-35622-5444'), + array('0-4X19-92611'), + array('0_45122_5244'), + array('2870#971#648'), + ); + } + + public function getValidIsbn13() + { + return array( + array('978-2723442282'), + array('978-2723442275'), + array('978-2723455046'), + array('978-2070546817'), + array('978-2711858835'), + array('978-2756406763'), + array('978-2870971642'), + array('978-2266238540'), + array('978-2851806420'), + array('978-0321812704'), + array('978-0451225245'), + array('978-0471292319'), + ); + } + + public function getInvalidIsbn13() + { + return array( + array('1234567890'), + array('987'), + array('0987656789'), + array(0), + array('0-4X19-9261981'), + array('978-0321513774'), + array('979-0431225385'), + array('980-0474292319'), + array('978_0451225245'), + array('978#0471292319'), + ); + } + + public function getValidIsbn() + { + return array_merge( + $this->getValidIsbn10(), + $this->getValidIsbn13() + ); + } + + public function getInvalidIsbn() + { + return array_merge( + $this->getInvalidIsbn10(), + $this->getInvalidIsbn13() + ); + } + + public function testNullIsValid() + { + $constraint = new Isbn(true); + $this->context + ->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate(null, $constraint); + } + + public function testEmptyStringIsValid() + { + $constraint = new Isbn(true); + $this->context + ->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate('', $constraint); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException + */ + public function testExpectsStringCompatibleType() + { + $constraint = new Isbn(true); + $this->validator->validate(new \stdClass(), $constraint); + } + + /** + * @dataProvider getValidIsbn10 + */ + public function testValidIsbn10($isbn) + { + $constraint = new Isbn(array('isbn10' => true)); + $this->context + ->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate($isbn, $constraint); + } + + /** + * @dataProvider getInvalidIsbn10 + */ + public function testInvalidIsbn10($isbn) + { + $constraint = new Isbn(array('isbn10' => true)); + $this->context + ->expects($this->once()) + ->method('addViolation') + ->with($constraint->isbn10Message); + + $this->validator->validate($isbn, $constraint); + } + + /** + * @dataProvider getValidIsbn13 + */ + public function testValidIsbn13($isbn) + { + $constraint = new Isbn(array('isbn13' => true)); + $this->context + ->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate($isbn, $constraint); + } + + /** + * @dataProvider getInvalidIsbn13 + */ + public function testInvalidIsbn13($isbn) + { + $constraint = new Isbn(array('isbn13' => true)); + $this->context + ->expects($this->once()) + ->method('addViolation') + ->with($constraint->isbn13Message); + + $this->validator->validate($isbn, $constraint); + } + + /** + * @dataProvider getValidIsbn + */ + public function testValidIsbn($isbn) + { + $constraint = new Isbn(array('isbn10' => true, 'isbn13' => true)); + $this->context + ->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate($isbn, $constraint); + } + + /** + * @dataProvider getInvalidIsbn + */ + public function testInvalidIsbn($isbn) + { + $constraint = new Isbn(array('isbn10' => true, 'isbn13' => true)); + $this->context + ->expects($this->once()) + ->method('addViolation') + ->with($constraint->bothIsbnMessage); + + $this->validator->validate($isbn, $constraint); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php new file mode 100644 index 000000000000..d9e48846625e --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php @@ -0,0 +1,220 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraints\Issn; +use Symfony\Component\Validator\Constraints\IssnValidator; + +/** + * @see https://en.wikipedia.org/wiki/Issn + */ +class IssnValidatorTest extends \PHPUnit_Framework_TestCase +{ + protected $context; + protected $validator; + + public function setUp() + { + $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); + $this->validator = new IssnValidator(); + $this->validator->initialize($this->context); + } + + public function getValidLowerCasedIssn() + { + return array( + array('2162-321x'), + array('2160-200x'), + array('1537-453x'), + array('1937-710x'), + array('0002-922x'), + array('1553-345x'), + array('1553-619x'), + ); + } + + public function getValidNonHyphenatedIssn() + { + return array( + array('2162321X'), + array('01896016'), + array('15744647'), + array('14350645'), + array('07174055'), + array('20905076'), + array('14401592'), + ); + } + + public function getFullValidIssn() + { + return array( + array('1550-7416'), + array('1539-8560'), + array('2156-5376'), + array('1119-023X'), + array('1684-5315'), + array('1996-0786'), + array('1684-5374'), + array('1996-0794') + ); + } + + public function getValidIssn() + { + return array_merge( + $this->getValidLowerCasedIssn(), + $this->getValidNonHyphenatedIssn(), + $this->getFullValidIssn() + ); + } + + public function getInvalidFormatedIssn() + { + return array( + array(0), + array('1539'), + array('2156-537A') + ); + } + + public function getInvalidValueIssn() + { + return array( + array('1119-0231'), + array('1684-5312'), + array('1996-0783'), + array('1684-537X'), + array('1996-0795') + ); + + } + + public function getInvalidIssn() + { + return array_merge( + $this->getInvalidFormatedIssn(), + $this->getInvalidValueIssn() + ); + } + + public function testNullIsValid() + { + $constraint = new Issn(); + $this->context + ->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate(null, $constraint); + } + + public function testEmptyStringIsValid() + { + $constraint = new Issn(); + $this->context + ->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate('', $constraint); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException + */ + public function testExpectsStringCompatibleType() + { + $constraint = new Issn(); + $this->validator->validate(new \stdClass(), $constraint); + } + + /** + * @dataProvider getValidLowerCasedIssn + */ + public function testCaseSensitiveIssns($issn) + { + $constraint = new Issn(array('caseSensitive' => true)); + $this->context + ->expects($this->once()) + ->method('addViolation') + ->with($constraint->message); + + $this->validator->validate($issn, $constraint); + } + + /** + * @dataProvider getValidNonHyphenatedIssn + */ + public function testRequireHyphenIssns($issn) + { + $constraint = new Issn(array('requireHyphen' => true)); + $this->context + ->expects($this->once()) + ->method('addViolation') + ->with($constraint->message); + + $this->validator->validate($issn, $constraint); + } + + /** + * @dataProvider getValidIssn + */ + public function testValidIssn($issn) + { + $constraint = new Issn(); + $this->context + ->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate($issn, $constraint); + } + + /** + * @dataProvider getInvalidFormatedIssn + */ + public function testInvalidFormatIssn($issn) + { + $constraint = new Issn(); + $this->context + ->expects($this->once()) + ->method('addViolation') + ->with($constraint->message); + + $this->validator->validate($issn, $constraint); + } + + /** + * @dataProvider getInvalidValueIssn + */ + public function testInvalidValueIssn($issn) + { + $constraint = new Issn(); + $this->context + ->expects($this->once()) + ->method('addViolation') + ->with($constraint->message); + + $this->validator->validate($issn, $constraint); + } + + /** + * @dataProvider getInvalidIssn + */ + public function testInvalidIssn($issn) + { + $constraint = new Issn(); + $this->context + ->expects($this->once()) + ->method('addViolation'); + + $this->validator->validate($issn, $constraint); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php index 49151d6302be..1230e3f322af 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php @@ -11,17 +11,18 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Language; use Symfony\Component\Validator\Constraints\LanguageValidator; -class LanguageValidatorTest extends LocalizedTestCase +class LanguageValidatorTest extends \PHPUnit_Framework_TestCase { protected $context; protected $validator; protected function setUp() { - parent::setUp(); + IntlTestHelper::requireIntl($this); $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); $this->validator = new LanguageValidator(); @@ -63,10 +64,6 @@ public function testExpectsStringCompatibleType() */ public function testValidLanguages($language) { - if (!class_exists('Symfony\Component\Locale\Locale')) { - $this->markTestSkipped('The "Locale" component is not available'); - } - $this->context->expects($this->never()) ->method('addViolation'); @@ -87,10 +84,6 @@ public function getValidLanguages() */ public function testInvalidLanguages($language) { - if (!class_exists('Symfony\Component\Locale\Locale')) { - $this->markTestSkipped('The "Locale" component is not available'); - } - $constraint = new Language(array( 'message' => 'myMessage' )); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php new file mode 100644 index 000000000000..2614905a88b5 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php @@ -0,0 +1,58 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraints\LessThanOrEqual; +use Symfony\Component\Validator\Constraints\LessThanOrEqualValidator; + +/** + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class LessThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase +{ + protected function createValidator() + { + return new LessThanOrEqualValidator(); + } + + protected function createConstraint(array $options) + { + return new LessThanOrEqual($options); + } + + /** + * {@inheritDoc} + */ + public function provideValidComparisons() + { + return array( + array(1, 2), + array(1, 1), + array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01')), + array(new \DateTime('2000-01-01'), new \DateTime('2020-01-01')), + array('a', 'a'), + array('a', 'z'), + ); + } + + /** + * {@inheritDoc} + */ + public function provideInvalidComparisons() + { + return array( + array(2, 1, '1', 'integer'), + array(new \DateTime('2010-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime'), + array('c', 'b', "'b'", 'string') + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php new file mode 100644 index 000000000000..61af9c6a2e69 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php @@ -0,0 +1,57 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraints\LessThan; +use Symfony\Component\Validator\Constraints\LessThanValidator; + +/** + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class LessThanValidatorTest extends AbstractComparisonValidatorTestCase +{ + protected function createValidator() + { + return new LessThanValidator(); + } + + protected function createConstraint(array $options) + { + return new LessThan($options); + } + + /** + * {@inheritDoc} + */ + public function provideValidComparisons() + { + return array( + array(1, 2), + array(new \DateTime('2000-01-01'), new \DateTime('2010-01-01')), + array('22', '333') + ); + } + + /** + * {@inheritDoc} + */ + public function provideInvalidComparisons() + { + return array( + array(3, 2, '2', 'integer'), + array(2, 2, '2', 'integer'), + array(new \DateTime('2010-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime'), + array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime'), + array('333', '22', "'22'", 'string') + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php index 167c49da1660..41feba0c7123 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php @@ -11,17 +11,18 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Locale; use Symfony\Component\Validator\Constraints\LocaleValidator; -class LocaleValidatorTest extends LocalizedTestCase +class LocaleValidatorTest extends \PHPUnit_Framework_TestCase { protected $context; protected $validator; protected function setUp() { - parent::setUp(); + IntlTestHelper::requireIntl($this); $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); $this->validator = new LocaleValidator(); @@ -63,10 +64,6 @@ public function testExpectsStringCompatibleType() */ public function testValidLocales($locale) { - if (!class_exists('Symfony\Component\Locale\Locale')) { - $this->markTestSkipped('The "Locale" component is not available'); - } - $this->context->expects($this->never()) ->method('addViolation'); @@ -89,10 +86,6 @@ public function getValidLocales() */ public function testInvalidLocales($locale) { - if (!class_exists('Symfony\Component\Locale\Locale')) { - $this->markTestSkipped('The "Locale" component is not available'); - } - $constraint = new Locale(array( 'message' => 'myMessage' )); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LocalizedTestCase.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LocalizedTestCase.php deleted file mode 100644 index a71c0890e393..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LocalizedTestCase.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -abstract class LocalizedTestCase extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - if (!extension_loaded('intl')) { - $this->markTestSkipped('The "intl" extension is not available'); - } - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MaxLengthValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MaxLengthValidatorTest.php deleted file mode 100644 index 56f3d054acba..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MaxLengthValidatorTest.php +++ /dev/null @@ -1,140 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Constraints\MaxLength; -use Symfony\Component\Validator\Constraints\MaxLengthValidator; - -class MaxLengthValidatorTest extends \PHPUnit_Framework_TestCase -{ - protected $context; - protected $validator; - - protected function setUp() - { - set_error_handler(array($this, "deprecationErrorHandler")); - - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new MaxLengthValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() - { - restore_error_handler(); - - $this->context = null; - $this->validator = null; - } - - public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - - public function testNullIsValid() - { - $this->context->expects($this->never()) - ->method('addViolation'); - - $this->validator->validate(null, new MaxLength(array('limit' => 5))); - } - - public function testEmptyStringIsValid() - { - $this->context->expects($this->never()) - ->method('addViolation'); - - $this->validator->validate('', new MaxLength(array('limit' => 5))); - } - - /** - * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException - */ - public function testExpectsStringCompatibleType() - { - $this->validator->validate(new \stdClass(), new MaxLength(array('limit' => 5))); - } - - /** - * @dataProvider getValidValues - */ - public function testValidValues($value, $mbOnly = false) - { - if ($mbOnly && !function_exists('mb_strlen')) { - $this->markTestSkipped('mb_strlen does not exist'); - } - - $this->context->expects($this->never()) - ->method('addViolation'); - - $constraint = new MaxLength(array('limit' => 5)); - $this->validator->validate($value, $constraint); - } - - public function getValidValues() - { - return array( - array(12345), - array('12345'), - array('üüüüü', true), - array('ééééé', true), - ); - } - - /** - * @dataProvider getInvalidValues - */ - public function testInvalidValues($value, $mbOnly = false) - { - if ($mbOnly && !function_exists('mb_strlen')) { - $this->markTestSkipped('mb_strlen does not exist'); - } - - $constraint = new MaxLength(array( - 'limit' => 5, - 'message' => 'myMessage' - )); - - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => (string) $value, - '{{ limit }}' => 5, - )), $this->identicalTo($value), 5); - - $this->validator->validate($value, $constraint); - } - - public function getInvalidValues() - { - return array( - array(123456), - array('123456'), - array('üüüüüü', true), - array('éééééé', true), - ); - } - - public function testConstraintGetDefaultOption() - { - $constraint = new MaxLength(array( - 'limit' => 5, - )); - - $this->assertEquals('limit', $constraint->getDefaultOption()); - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MaxValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MaxValidatorTest.php deleted file mode 100644 index 41c3a39e6118..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MaxValidatorTest.php +++ /dev/null @@ -1,124 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Constraints\Max; -use Symfony\Component\Validator\Constraints\MaxValidator; - -class MaxValidatorTest extends \PHPUnit_Framework_TestCase -{ - protected $context; - protected $validator; - - protected function setUp() - { - set_error_handler(array($this, "deprecationErrorHandler")); - - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new MaxValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() - { - restore_error_handler(); - - $this->context = null; - $this->validator = null; - } - - public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - - public function testNullIsValid() - { - $this->context->expects($this->never()) - ->method('addViolation'); - - $this->validator->validate(null, new Max(array('limit' => 10))); - } - - public function testEmptyStringIsValid() - { - $this->context->expects($this->never()) - ->method('addViolation'); - - $this->validator->validate('', new Max(array('limit' => 10))); - } - - /** - * @dataProvider getValidValues - */ - public function testValidValues($value) - { - $this->context->expects($this->never()) - ->method('addViolation'); - - $constraint = new Max(array('limit' => 10)); - $this->validator->validate($value, $constraint); - } - - public function getValidValues() - { - return array( - array(9.999999), - array(10), - array(10.0), - array('10'), - ); - } - - /** - * @dataProvider getInvalidValues - */ - public function testInvalidValues($value) - { - $constraint = new Max(array( - 'limit' => 10, - 'message' => 'myMessage', - 'invalidMessage' => 'myMessage' - )); - - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $value, - '{{ limit }}' => 10, - )); - - $this->validator->validate($value, $constraint); - } - - public function getInvalidValues() - { - return array( - array(10.00001), - array('10.00001'), - array(new \stdClass()), - ); - } - - public function testConstraintGetDefaultOption() - { - $constraint = new Max(array( - 'limit' => 10, - )); - - $this->assertEquals('limit', $constraint->getDefaultOption()); - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MinLengthValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MinLengthValidatorTest.php deleted file mode 100644 index 7975b2339777..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MinLengthValidatorTest.php +++ /dev/null @@ -1,140 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Constraints\MinLength; -use Symfony\Component\Validator\Constraints\MinLengthValidator; - -class MinLengthValidatorTest extends \PHPUnit_Framework_TestCase -{ - protected $context; - protected $validator; - - protected function setUp() - { - set_error_handler(array($this, "deprecationErrorHandler")); - - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new MinLengthValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() - { - restore_error_handler(); - - $this->context = null; - $this->validator = null; - } - - public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - - public function testNullIsValid() - { - $this->context->expects($this->never()) - ->method('addViolation'); - - $this->validator->validate(null, new MinLength(array('limit' => 6))); - } - - public function testEmptyStringIsValid() - { - $this->context->expects($this->never()) - ->method('addViolation'); - - $this->validator->validate('', new MinLength(array('limit' => 6))); - } - - /** - * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException - */ - public function testExpectsStringCompatibleType() - { - $this->validator->validate(new \stdClass(), new MinLength(array('limit' => 5))); - } - - /** - * @dataProvider getValidValues - */ - public function testValidValues($value, $mbOnly = false) - { - if ($mbOnly && !function_exists('mb_strlen')) { - $this->markTestSkipped('mb_strlen does not exist'); - } - - $this->context->expects($this->never()) - ->method('addViolation'); - - $constraint = new MinLength(array('limit' => 6)); - $this->validator->validate($value, $constraint); - } - - public function getValidValues() - { - return array( - array(123456), - array('123456'), - array('üüüüüü', true), - array('éééééé', true), - ); - } - - /** - * @dataProvider getInvalidValues - */ - public function testInvalidValues($value, $mbOnly = false) - { - if ($mbOnly && !function_exists('mb_strlen')) { - $this->markTestSkipped('mb_strlen does not exist'); - } - - $constraint = new MinLength(array( - 'limit' => 5, - 'message' => 'myMessage' - )); - - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => (string) $value, - '{{ limit }}' => 5, - )), $this->identicalTo($value), 5); - - $this->validator->validate($value, $constraint); - } - - public function getInvalidValues() - { - return array( - array(1234), - array('1234'), - array('üüüü', true), - array('éééé', true), - ); - } - - public function testConstraintGetDefaultOption() - { - $constraint = new MinLength(array( - 'limit' => 5, - )); - - $this->assertEquals('limit', $constraint->getDefaultOption()); - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MinValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MinValidatorTest.php deleted file mode 100644 index 64c770afbbc0..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/MinValidatorTest.php +++ /dev/null @@ -1,121 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Constraints\Min; -use Symfony\Component\Validator\Constraints\MinValidator; - -class MinValidatorTest extends \PHPUnit_Framework_TestCase -{ - protected $context; - protected $validator; - - protected function setUp() - { - set_error_handler(array($this, "deprecationErrorHandler")); - - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new MinValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() - { - restore_error_handler(); - } - - public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - - public function testNullIsValid() - { - $this->context->expects($this->never()) - ->method('addViolation'); - - $this->validator->validate(null, new Min(array('limit' => 10))); - } - - public function testEmptyStringIsValid() - { - $this->context->expects($this->never()) - ->method('addViolation'); - - $this->validator->validate('', new Min(array('limit' => 10))); - } - - /** - * @dataProvider getValidValues - */ - public function testValidValues($value) - { - $this->context->expects($this->never()) - ->method('addViolation'); - - $constraint = new Min(array('limit' => 10)); - $this->validator->validate($value, $constraint); - } - - public function getValidValues() - { - return array( - array(10.00001), - array('10.00001'), - array(10), - array(10.0), - ); - } - - /** - * @dataProvider getInvalidValues - */ - public function testInvalidValues($value) - { - $constraint = new Min(array( - 'limit' => 10, - 'message' => 'myMessage', - 'invalidMessage' => 'myMessage' - )); - - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $value, - '{{ limit }}' => 10, - )); - - $this->validator->validate($value, $constraint); - } - - public function getInvalidValues() - { - return array( - array(9.999999), - array('9.999999'), - array(new \stdClass()), - ); - } - - public function testConstraintGetDefaultOption() - { - $constraint = new Min(array( - 'limit' => 10, - )); - - $this->assertEquals('limit', $constraint->getDefaultOption()); - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php new file mode 100644 index 000000000000..d7c446a1e277 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php @@ -0,0 +1,57 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraints\NotEqualTo; +use Symfony\Component\Validator\Constraints\NotEqualToValidator; +use Symfony\Component\Validator\Tests\Constraints\AbstractComparisonValidatorTestCase; + +/** + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class NotEqualToValidatorTest extends AbstractComparisonValidatorTestCase +{ + protected function createValidator() + { + return new NotEqualToValidator(); + } + + protected function createConstraint(array $options) + { + return new NotEqualTo($options); + } + + /** + * {@inheritDoc} + */ + public function provideValidComparisons() + { + return array( + array(1, 2), + array('22', '333'), + array(new \DateTime('2001-01-01'), new \DateTime('2000-01-01')) + ); + } + + /** + * {@inheritDoc} + */ + public function provideInvalidComparisons() + { + return array( + array(3, 3, '3', 'integer'), + array('2', 2, '2', 'integer'), + array('a', 'a', "'a'", 'string'), + array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime') + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php new file mode 100644 index 000000000000..48b1931d9f19 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php @@ -0,0 +1,60 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraints\NotIdenticalTo; +use Symfony\Component\Validator\Constraints\NotIdenticalToValidator; +use Symfony\Component\Validator\Tests\Constraints\AbstractComparisonValidatorTestCase; + +/** + * @author Daniel Holmes <daniel@danielholmes.org> + */ +class NotIdenticalToValidatorTest extends AbstractComparisonValidatorTestCase +{ + protected function createValidator() + { + return new NotIdenticalToValidator(); + } + + protected function createConstraint(array $options) + { + return new NotIdenticalTo($options); + } + + /** + * {@inheritDoc} + */ + public function provideValidComparisons() + { + return array( + array(1, 2), + array('2', 2), + array('22', '333'), + array(new \DateTime('2001-01-01'), new \DateTime('2000-01-01')), + array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01')) + ); + } + + /** + * {@inheritDoc} + */ + public function provideInvalidComparisons() + { + $date = new \DateTime('2000-01-01'); + + return array( + array(3, 3, '3', 'integer'), + array('a', 'a', "'a'", 'string'), + array($date, $date, '2000-01-01 00:00:00', 'DateTime') + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ExecutionContextTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ExecutionContextTest.php index 0cd92f711f71..354a2463cf5d 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ExecutionContextTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ExecutionContextTest.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Validator\Tests; -use Symfony\Component\Validator\Mapping\PropertyMetadata; -use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\ExecutionContext; @@ -64,57 +62,12 @@ protected function tearDown() $this->context = null; } - public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - public function testInit() { $this->assertCount(0, $this->context->getViolations()); $this->assertSame('Root', $this->context->getRoot()); $this->assertSame('foo.bar', $this->context->getPropertyPath()); $this->assertSame('Group', $this->context->getGroup()); - - $this->visitor->expects($this->once()) - ->method('getGraphWalker') - ->will($this->returnValue('GRAPHWALKER')); - - // BC - set_error_handler(array($this, "deprecationErrorHandler")); - $this->assertNull($this->context->getCurrentClass()); - $this->assertNull($this->context->getCurrentProperty()); - $this->assertSame('GRAPHWALKER', $this->context->getGraphWalker()); - $this->assertSame($this->metadataFactory, $this->context->getMetadataFactory()); - restore_error_handler(); - } - - public function testInitWithClassMetadata() - { - // BC - set_error_handler(array($this, "deprecationErrorHandler")); - $this->metadata = new ClassMetadata(__NAMESPACE__ . '\ExecutionContextTest_TestClass'); - $this->context = new ExecutionContext($this->globalContext, $this->translator, self::TRANS_DOMAIN, $this->metadata, 'currentValue', 'Group', 'foo.bar'); - - $this->assertSame(__NAMESPACE__ . '\ExecutionContextTest_TestClass', $this->context->getCurrentClass()); - $this->assertNull($this->context->getCurrentProperty()); - restore_error_handler(); - } - - public function testInitWithPropertyMetadata() - { - // BC - set_error_handler(array($this, "deprecationErrorHandler")); - $this->metadata = new PropertyMetadata(__NAMESPACE__ . '\ExecutionContextTest_TestClass', 'myProperty'); - $this->context = new ExecutionContext($this->globalContext, $this->translator, self::TRANS_DOMAIN, $this->metadata, 'currentValue', 'Group', 'foo.bar'); - - $this->assertSame(__NAMESPACE__ . '\ExecutionContextTest_TestClass', $this->context->getCurrentClass()); - $this->assertSame('myProperty', $this->context->getCurrentProperty()); - restore_error_handler(); } public function testClone() @@ -206,91 +159,6 @@ public function testAddViolationUsesPassedNullValue() )), $this->context->getViolations()); } - public function testAddViolationAtPath() - { - $this->translator->expects($this->once()) - ->method('trans') - ->with('Error', array('foo' => 'bar')) - ->will($this->returnValue('Translated error')); - - // override preconfigured property path - set_error_handler(array($this, "deprecationErrorHandler")); - $this->context->addViolationAtPath('bar.baz', 'Error', array('foo' => 'bar'), 'invalid'); - restore_error_handler(); - - $this->assertEquals(new ConstraintViolationList(array( - new ConstraintViolation( - 'Translated error', - 'Error', - array('foo' => 'bar'), - 'Root', - 'bar.baz', - 'invalid' - ), - )), $this->context->getViolations()); - } - - public function testAddViolationAtPathUsesPreconfiguredValueIfNotPassed() - { - $this->translator->expects($this->once()) - ->method('trans') - ->with('Error', array()) - ->will($this->returnValue('Translated error')); - - set_error_handler(array($this, "deprecationErrorHandler")); - $this->context->addViolationAtPath('bar.baz', 'Error'); - restore_error_handler(); - - $this->assertEquals(new ConstraintViolationList(array( - new ConstraintViolation( - 'Translated error', - 'Error', - array(), - 'Root', - 'bar.baz', - 'currentValue' - ), - )), $this->context->getViolations()); - } - - public function testAddViolationAtPathUsesPassedNullValue() - { - $this->translator->expects($this->once()) - ->method('trans') - ->with('Error', array('foo' => 'bar')) - ->will($this->returnValue('Translated error')); - $this->translator->expects($this->once()) - ->method('transChoice') - ->with('Choice error', 3, array('foo' => 'bar')) - ->will($this->returnValue('Translated choice error')); - - // passed null value should override preconfigured value "invalid" - set_error_handler(array($this, "deprecationErrorHandler")); - $this->context->addViolationAtPath('bar.baz', 'Error', array('foo' => 'bar'), null); - $this->context->addViolationAtPath('bar.baz', 'Choice error', array('foo' => 'bar'), null, 3); - restore_error_handler(); - - $this->assertEquals(new ConstraintViolationList(array( - new ConstraintViolation( - 'Translated error', - 'Error', - array('foo' => 'bar'), - 'Root', - 'bar.baz', - null - ), - new ConstraintViolation( - 'Translated choice error', - 'Choice error', - array('foo' => 'bar'), - 'Root', - 'bar.baz', - null, - 3 - ), - )), $this->context->getViolations()); - } - public function testAddViolationAt() { $this->translator->expects($this->once()) @@ -299,9 +167,7 @@ public function testAddViolationAt() ->will($this->returnValue('Translated error')); // override preconfigured property path - set_error_handler(array($this, "deprecationErrorHandler")); $this->context->addViolationAt('bam.baz', 'Error', array('foo' => 'bar'), 'invalid'); - restore_error_handler(); $this->assertEquals(new ConstraintViolationList(array( new ConstraintViolation( @@ -322,9 +188,7 @@ public function testAddViolationAtUsesPreconfiguredValueIfNotPassed() ->with('Error', array()) ->will($this->returnValue('Translated error')); - set_error_handler(array($this, "deprecationErrorHandler")); $this->context->addViolationAt('bam.baz', 'Error'); - restore_error_handler(); $this->assertEquals(new ConstraintViolationList(array( new ConstraintViolation( @@ -350,10 +214,8 @@ public function testAddViolationAtUsesPassedNullValue() ->will($this->returnValue('Translated choice error')); // passed null value should override preconfigured value "invalid" - set_error_handler(array($this, "deprecationErrorHandler")); $this->context->addViolationAt('bam.baz', 'Error', array('foo' => 'bar'), null); $this->context->addViolationAt('bam.baz', 'Choice error', array('foo' => 'bar'), null, 2); - restore_error_handler(); $this->assertEquals(new ConstraintViolationList(array( new ConstraintViolation( diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Entity.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Entity.php index 002b6ed1d4ad..e1cb3e04902c 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Entity.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Entity.php @@ -33,8 +33,8 @@ class Entity extends EntityParent implements EntityInterface protected $firstName; protected $lastName; public $reference; - private $internal; + public $data = 'Overridden data'; public function __construct($internal = null) { @@ -43,7 +43,7 @@ public function __construct($internal = null) public function getInternal() { - return $this->internal . ' from getter'; + return $this->internal.' from getter'; } /** @@ -53,4 +53,9 @@ public function getLastName() { return $this->lastName; } + + public function getData() + { + return 'Overridden data'; + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/EntityParent.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/EntityParent.php index d12d9435f456..422bb28d0b5e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/EntityParent.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/EntityParent.php @@ -17,9 +17,15 @@ class EntityParent { protected $firstName; private $internal; + private $data = 'Data'; /** * @NotNull */ protected $other; + + public function getData() + { + return 'Data'; + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php index 1276ca52839d..ba39823be6e1 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php @@ -26,11 +26,11 @@ public function getMetadataFor($class) } if (!is_string($class)) { - throw new NoSuchMetadataException('No metadata for type ' . gettype($class)); + throw new NoSuchMetadataException(sprintf('No metadata for type %s', gettype($class))); } if (!isset($this->metadatas[$class])) { - throw new NoSuchMetadataException('No metadata for "' . $class . '"'); + throw new NoSuchMetadataException(sprintf('No metadata for "%s"', $class)); } return $this->metadatas[$class]; diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/GraphWalkerTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/GraphWalkerTest.php deleted file mode 100644 index cafcc7aa50d5..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/GraphWalkerTest.php +++ /dev/null @@ -1,592 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests; - -use Symfony\Component\Validator\Tests\Fixtures\ConstraintAValidator; -use Symfony\Component\Validator\DefaultTranslator; -use Symfony\Component\Validator\ValidationVisitor; -use Symfony\Component\Validator\Tests\Fixtures\Entity; -use Symfony\Component\Validator\Tests\Fixtures\Reference; -use Symfony\Component\Validator\Tests\Fixtures\FakeMetadataFactory; -use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; -use Symfony\Component\Validator\Tests\Fixtures\FailingConstraint; -use Symfony\Component\Validator\GraphWalker; -use Symfony\Component\Validator\ConstraintViolation; -use Symfony\Component\Validator\ConstraintViolationList; -use Symfony\Component\Validator\ConstraintValidatorFactory; -use Symfony\Component\Validator\Mapping\ClassMetadata; -use Symfony\Component\Validator\Constraints\Valid; -use Symfony\Component\Validator\Constraints\Collection; - -class GraphWalkerTest extends \PHPUnit_Framework_TestCase -{ - const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity'; - - /** - * @var ValidationVisitor - */ - private $visitor; - - /** - * @var FakeMetadataFactory - */ - protected $metadataFactory; - - /** - * @var GraphWalker - */ - protected $walker; - - /** - * @var ClassMetadata - */ - protected $metadata; - - protected function setUp() - { - set_error_handler(array($this, "deprecationErrorHandler")); - - $this->metadataFactory = new FakeMetadataFactory(); - $this->visitor = new ValidationVisitor('Root', $this->metadataFactory, new ConstraintValidatorFactory(), new DefaultTranslator()); - $this->walker = $this->visitor->getGraphWalker(); - $this->metadata = new ClassMetadata(self::CLASSNAME); - $this->metadataFactory->addMetadata($this->metadata); - } - - protected function tearDown() - { - restore_error_handler(); - - $this->metadataFactory = null; - $this->visitor = null; - $this->walker = null; - $this->metadata = null; - } - - public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - - public function testWalkObjectPassesCorrectClassAndProperty() - { - $this->metadata->addConstraint(new ConstraintA()); - - $entity = new Entity(); - $this->walker->walkObject($this->metadata, $entity, 'Default', ''); - - $context = ConstraintAValidator::$passedContext; - - $this->assertEquals('Symfony\Component\Validator\Tests\Fixtures\Entity', $context->getCurrentClass()); - $this->assertNull($context->getCurrentProperty()); - } - - public function testWalkObjectValidatesConstraints() - { - $this->metadata->addConstraint(new ConstraintA()); - - $this->walker->walkObject($this->metadata, new Entity(), 'Default', ''); - - $this->assertCount(1, $this->walker->getViolations()); - } - - public function testWalkObjectTwiceValidatesConstraintsOnce() - { - $this->metadata->addConstraint(new ConstraintA()); - - $entity = new Entity(); - - $this->walker->walkObject($this->metadata, $entity, 'Default', ''); - $this->walker->walkObject($this->metadata, $entity, 'Default', ''); - - $this->assertCount(1, $this->walker->getViolations()); - } - - public function testWalkObjectOnceInVisitorAndOnceInWalkerValidatesConstraintsOnce() - { - $this->metadata->addConstraint(new ConstraintA()); - - $entity = new Entity(); - - $this->visitor->validate($entity, 'Default', ''); - $this->walker->walkObject($this->metadata, $entity, 'Default', ''); - - $this->assertCount(1, $this->walker->getViolations()); - } - - public function testWalkDifferentObjectsValidatesTwice() - { - $this->metadata->addConstraint(new ConstraintA()); - - $this->walker->walkObject($this->metadata, new Entity(), 'Default', ''); - $this->walker->walkObject($this->metadata, new Entity(), 'Default', ''); - - $this->assertCount(2, $this->walker->getViolations()); - } - - public function testWalkObjectTwiceInDifferentGroupsValidatesTwice() - { - $this->metadata->addConstraint(new ConstraintA()); - $this->metadata->addConstraint(new ConstraintA(array('groups' => 'Custom'))); - - $entity = new Entity(); - - $this->walker->walkObject($this->metadata, $entity, 'Default', ''); - $this->walker->walkObject($this->metadata, $entity, 'Custom', ''); - - $this->assertCount(2, $this->walker->getViolations()); - } - - public function testWalkObjectValidatesPropertyConstraints() - { - $this->metadata->addPropertyConstraint('firstName', new ConstraintA()); - - $this->walker->walkObject($this->metadata, new Entity(), 'Default', ''); - - $this->assertCount(1, $this->walker->getViolations()); - } - - public function testWalkObjectValidatesGetterConstraints() - { - $this->metadata->addGetterConstraint('lastName', new ConstraintA()); - - $this->walker->walkObject($this->metadata, new Entity(), 'Default', ''); - - $this->assertCount(1, $this->walker->getViolations()); - } - - public function testWalkObjectInDefaultGroupTraversesGroupSequence() - { - $entity = new Entity(); - - $this->metadata->addPropertyConstraint('firstName', new FailingConstraint(array( - 'groups' => 'First', - ))); - $this->metadata->addGetterConstraint('lastName', new FailingConstraint(array( - 'groups' => 'Default', - ))); - $this->metadata->setGroupSequence(array('First', $this->metadata->getDefaultGroup())); - - $this->walker->walkObject($this->metadata, $entity, 'Default', ''); - - // After validation of group "First" failed, no more group was - // validated - $violations = new ConstraintViolationList(); - $violations->add(new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'firstName', - '' - )); - - $this->assertEquals($violations, $this->walker->getViolations()); - } - - public function testWalkObjectInGroupSequencePropagatesDefaultGroup() - { - $entity = new Entity(); - $entity->reference = new Reference(); - - $this->metadata->addPropertyConstraint('reference', new Valid()); - $this->metadata->setGroupSequence(array($this->metadata->getDefaultGroup())); - - $referenceMetadata = new ClassMetadata(get_class($entity->reference)); - $referenceMetadata->addConstraint(new FailingConstraint(array( - // this constraint is only evaluated if group "Default" is - // propagated to the reference - 'groups' => 'Default', - ))); - $this->metadataFactory->addMetadata($referenceMetadata); - - $this->walker->walkObject($this->metadata, $entity, 'Default', ''); - - // The validation of the reference's FailingConstraint in group - // "Default" was launched - $violations = new ConstraintViolationList(); - $violations->add(new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'reference', - $entity->reference - )); - - $this->assertEquals($violations, $this->walker->getViolations()); - } - - public function testWalkObjectInOtherGroupTraversesNoGroupSequence() - { - $entity = new Entity(); - - $this->metadata->addPropertyConstraint('firstName', new FailingConstraint(array( - 'groups' => 'First', - ))); - $this->metadata->addGetterConstraint('lastName', new FailingConstraint(array( - 'groups' => $this->metadata->getDefaultGroup(), - ))); - $this->metadata->setGroupSequence(array('First', $this->metadata->getDefaultGroup())); - - $this->walker->walkObject($this->metadata, $entity, $this->metadata->getDefaultGroup(), ''); - - // Only group "Second" was validated - $violations = new ConstraintViolationList(); - $violations->add(new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'lastName', - '' - )); - - $this->assertEquals($violations, $this->walker->getViolations()); - } - - public function testWalkPropertyPassesCorrectClassAndProperty() - { - $this->metadata->addPropertyConstraint('firstName', new ConstraintA()); - - $this->walker->walkPropertyValue($this->metadata, 'firstName', 'value', 'Default', ''); - - $context = ConstraintAValidator::$passedContext; - - $this->assertEquals('Symfony\Component\Validator\Tests\Fixtures\Entity', $context->getCurrentClass()); - $this->assertEquals('firstName', $context->getCurrentProperty()); - } - - public function testWalkPropertyValueValidatesConstraints() - { - $this->metadata->addPropertyConstraint('firstName', new ConstraintA()); - - $this->walker->walkPropertyValue($this->metadata, 'firstName', 'value', 'Default', ''); - - $this->assertCount(1, $this->walker->getViolations()); - } - - public function testWalkCascadedPropertyValidatesReferences() - { - $entity = new Entity(); - $entityMetadata = new ClassMetadata(get_class($entity)); - $this->metadataFactory->addMetadata($entityMetadata); - - // add a constraint for the entity that always fails - $entityMetadata->addConstraint(new FailingConstraint()); - - // validate entity when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid()); - - // invoke validation on an object - $this->walker->walkPropertyValue( - $this->metadata, - 'reference', - $entity, // object! - 'Default', - 'path' - ); - - $violations = new ConstraintViolationList(); - $violations->add(new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'path', - $entity - )); - - $this->assertEquals($violations, $this->walker->getViolations()); - } - - public function testWalkCascadedPropertyValidatesArraysByDefault() - { - $entity = new Entity(); - $entityMetadata = new ClassMetadata(get_class($entity)); - $this->metadataFactory->addMetadata($entityMetadata); - - // add a constraint for the entity that always fails - $entityMetadata->addConstraint(new FailingConstraint()); - - // validate array when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid()); - - $this->walker->walkPropertyValue( - $this->metadata, - 'reference', - array('key' => $entity), // array! - 'Default', - 'path' - ); - - $violations = new ConstraintViolationList(); - $violations->add(new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'path[key]', - $entity - )); - - $this->assertEquals($violations, $this->walker->getViolations()); - } - - public function testWalkCascadedPropertyValidatesTraversableByDefault() - { - $entity = new Entity(); - $entityMetadata = new ClassMetadata(get_class($entity)); - $this->metadataFactory->addMetadata($entityMetadata); - $this->metadataFactory->addMetadata(new ClassMetadata('ArrayIterator')); - - // add a constraint for the entity that always fails - $entityMetadata->addConstraint(new FailingConstraint()); - - // validate array when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid()); - - $this->walker->walkPropertyValue( - $this->metadata, - 'reference', - new \ArrayIterator(array('key' => $entity)), - 'Default', - 'path' - ); - - $violations = new ConstraintViolationList(); - $violations->add(new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'path[key]', - $entity - )); - - $this->assertEquals($violations, $this->walker->getViolations()); - } - - public function testWalkCascadedPropertyDoesNotValidateTraversableIfDisabled() - { - $entity = new Entity(); - $entityMetadata = new ClassMetadata(get_class($entity)); - $this->metadataFactory->addMetadata($entityMetadata); - $this->metadataFactory->addMetadata(new ClassMetadata('ArrayIterator')); - - // add a constraint for the entity that always fails - $entityMetadata->addConstraint(new FailingConstraint()); - - // validate array when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid(array( - 'traverse' => false, - ))); - - $this->walker->walkPropertyValue( - $this->metadata, - 'reference', - new \ArrayIterator(array('key' => $entity)), - 'Default', - 'path' - ); - - $violations = new ConstraintViolationList(); - - $this->assertEquals($violations, $this->walker->getViolations()); - } - - public function testWalkCascadedPropertyDoesNotRecurseByDefault() - { - $entity = new Entity(); - $entityMetadata = new ClassMetadata(get_class($entity)); - $this->metadataFactory->addMetadata($entityMetadata); - $this->metadataFactory->addMetadata(new ClassMetadata('ArrayIterator')); - - // add a constraint for the entity that always fails - $entityMetadata->addConstraint(new FailingConstraint()); - - // validate iterator when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid()); - - $this->walker->walkPropertyValue( - $this->metadata, - 'reference', - new \ArrayIterator(array( - // The inner iterator should not be traversed by default - 'key' => new \ArrayIterator(array( - 'nested' => $entity, - )), - )), - 'Default', - 'path' - ); - - $violations = new ConstraintViolationList(); - - $this->assertEquals($violations, $this->walker->getViolations()); - } - - public function testWalkCascadedPropertyRecursesIfDeepIsSet() - { - $entity = new Entity(); - $entityMetadata = new ClassMetadata(get_class($entity)); - $this->metadataFactory->addMetadata($entityMetadata); - $this->metadataFactory->addMetadata(new ClassMetadata('ArrayIterator')); - - // add a constraint for the entity that always fails - $entityMetadata->addConstraint(new FailingConstraint()); - - // validate iterator when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid(array( - 'deep' => true, - ))); - - $this->walker->walkPropertyValue( - $this->metadata, - 'reference', - new \ArrayIterator(array( - // The inner iterator should now be traversed - 'key' => new \ArrayIterator(array( - 'nested' => $entity, - )), - )), - 'Default', - 'path' - ); - - $violations = new ConstraintViolationList(); - $violations->add(new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'path[key][nested]', - $entity - )); - - $this->assertEquals($violations, $this->walker->getViolations()); - } - - public function testWalkCascadedPropertyDoesNotValidateNestedScalarValues() - { - // validate array when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid()); - - $this->walker->walkPropertyValue( - $this->metadata, - 'reference', - array('scalar', 'values'), - 'Default', - 'path' - ); - - $violations = new ConstraintViolationList(); - - $this->assertEquals($violations, $this->walker->getViolations()); - } - - public function testWalkCascadedPropertyDoesNotValidateNullValues() - { - $this->metadata->addPropertyConstraint('reference', new Valid()); - - $this->walker->walkPropertyValue( - $this->metadata, - 'reference', - null, - 'Default', - '' - ); - - $this->assertCount(0, $this->walker->getViolations()); - } - - public function testWalkCascadedPropertyRequiresObjectOrArray() - { - $this->metadata->addPropertyConstraint('reference', new Valid()); - - $this->setExpectedException('Symfony\Component\Validator\Exception\NoSuchMetadataException'); - - $this->walker->walkPropertyValue( - $this->metadata, - 'reference', - 'no object', - 'Default', - '' - ); - } - - public function testWalkConstraintBuildsAViolationIfFailed() - { - $constraint = new ConstraintA(); - - $this->walker->walkConstraint($constraint, 'foobar', 'Default', 'firstName.path'); - - $violations = new ConstraintViolationList(); - $violations->add(new ConstraintViolation( - 'message', - 'message', - array('param' => 'value'), - 'Root', - 'firstName.path', - 'foobar' - )); - - $this->assertEquals($violations, $this->walker->getViolations()); - } - - public function testWalkConstraintBuildsNoViolationIfSuccessful() - { - $constraint = new ConstraintA(); - - $this->walker->walkConstraint($constraint, 'VALID', 'Default', 'firstName.path'); - - $this->assertCount(0, $this->walker->getViolations()); - } - - public function testWalkObjectUsesCorrectPropertyPathInViolationsWhenUsingCollections() - { - $constraint = new Collection(array( - 'foo' => new ConstraintA(), - 'bar' => new ConstraintA(), - )); - - $this->walker->walkConstraint($constraint, array('foo' => 'VALID'), 'Default', 'collection'); - $violations = $this->walker->getViolations(); - $this->assertEquals('collection[bar]', $violations[0]->getPropertyPath()); - } - - public function testWalkObjectUsesCorrectPropertyPathInViolationsWhenUsingNestedCollections() - { - $constraint = new Collection(array( - 'foo' => new Collection(array( - 'foo' => new ConstraintA(), - 'bar' => new ConstraintA(), - )), - )); - - $this->walker->walkConstraint($constraint, array('foo' => array('foo' => 'VALID')), 'Default', 'collection'); - $violations = $this->walker->getViolations(); - $this->assertEquals('collection[foo][bar]', $violations[0]->getPropertyPath()); - } - - protected function getProperty($property) - { - $p = new \ReflectionProperty($this->walker, $property); - $p->setAccessible(true); - - return $p->getValue($this->walker); - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php index d5ec32a039e0..6f842cd6d1e7 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php @@ -22,21 +22,10 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity'; const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent'; - public function handle($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - public function testLoadClassMetadata() { $factory = new ClassMetadataFactory(new TestLoader()); - set_error_handler(array($this, 'handle')); - $metadata = $factory->getClassMetadata(self::PARENTCLASS); - restore_error_handler(); + $metadata = $factory->getMetadataFor(self::PARENTCLASS); $constraints = array( new ConstraintA(array('groups' => array('Default', 'EntityParent'))), @@ -48,9 +37,7 @@ public function testLoadClassMetadata() public function testMergeParentConstraints() { $factory = new ClassMetadataFactory(new TestLoader()); - set_error_handler(array($this, 'handle')); - $metadata = $factory->getClassMetadata(self::CLASSNAME); - restore_error_handler(); + $metadata = $factory->getMetadataFor(self::CLASSNAME); $constraints = array( new ConstraintA(array('groups' => array( @@ -94,9 +81,7 @@ public function testWriteMetadataToCache() $tester->assertEquals($constraints, $metadata->getConstraints()); })); - set_error_handler(array($this, 'handle')); - $metadata = $factory->getClassMetadata(self::PARENTCLASS); - restore_error_handler(); + $metadata = $factory->getMetadataFor(self::PARENTCLASS); $this->assertEquals(self::PARENTCLASS, $metadata->getClassName()); $this->assertEquals($constraints, $metadata->getConstraints()); @@ -121,9 +106,7 @@ public function testReadMetadataFromCache() ->method('read') ->will($this->returnValue($metadata)); - set_error_handler(array($this, 'handle')); - $this->assertEquals($metadata,$factory->getClassMetadata(self::PARENTCLASS)); - restore_error_handler(); + $this->assertEquals($metadata,$factory->getMetadataFor(self::PARENTCLASS)); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php index d38225aa2e06..6549bc8b9927 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php @@ -35,4 +35,12 @@ public function testGetPropertyValueFromPublicGetter() $this->assertEquals('foobar from getter', $metadata->getPropertyValue($entity)); } + + public function testGetPropertyValueFromOverriddenPublicGetter() + { + $entity = new Entity(); + $metadata = new GetterMetadata(self::CLASSNAME, 'data'); + + $this->assertEquals('Overridden data', $metadata->getPropertyValue($entity)); + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php index 301ef0e50e29..7723349e94d8 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php @@ -34,10 +34,10 @@ public function testCallsActualFileLoaderForMetadata() public function getFilesLoader(LoaderInterface $loader) { return $this->getMockForAbstractClass('Symfony\Component\Validator\Tests\Fixtures\FilesLoader', array(array( - __DIR__ . '/constraint-mapping.xml', - __DIR__ . '/constraint-mapping.yaml', - __DIR__ . '/constraint-mapping.test', - __DIR__ . '/constraint-mapping.txt', + __DIR__.'/constraint-mapping.xml', + __DIR__.'/constraint-mapping.yaml', + __DIR__.'/constraint-mapping.test', + __DIR__.'/constraint-mapping.txt', ), $loader)); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php index 22478e606d0e..1677b81b1f62 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php @@ -82,7 +82,7 @@ public function testLoadGroupSequenceProvider() } /** - * @expectedException Symfony\Component\Validator\Exception\MappingException + * @expectedException \Symfony\Component\Validator\Exception\MappingException * @expectedExceptionMessage Document types are not allowed. */ public function testDocTypeIsNotAllowed() diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml index 73398bd48be3..946200ba11ca 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml @@ -2,7 +2,7 @@ <constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd"> + xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> <namespace prefix="custom">Symfony\Component\Validator\Tests\Fixtures\</namespace> diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/withdoctype.xml b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/withdoctype.xml index 0c5e890cbdfe..0beacc32cdac 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/withdoctype.xml +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/withdoctype.xml @@ -2,6 +2,6 @@ <!DOCTYPE foo> <constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd"> + xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> <class name="Symfony\Component\Validator\Tests\Fixtures\Entity" /> </constraint-mapping> diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php index 747a36b39a77..1abe58de7238 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php @@ -77,7 +77,7 @@ public function getPropertyValue($object) { } - protected function newReflectionMember() + protected function newReflectionMember($object) { } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/PropertyMetadataTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/PropertyMetadataTest.php index aeabefc5bc45..f411d950e170 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/PropertyMetadataTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/PropertyMetadataTest.php @@ -17,6 +17,7 @@ class PropertyMetadataTest extends \PHPUnit_Framework_TestCase { const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity'; + const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent'; public function testInvalidPropertyName() { @@ -32,4 +33,13 @@ public function testGetPropertyValueFromPrivateProperty() $this->assertEquals('foobar', $metadata->getPropertyValue($entity)); } + + public function testGetPropertyValueFromOverriddenPrivateProperty() + { + $entity = new Entity('foobar'); + $metadata = new PropertyMetadata(self::PARENTCLASS, 'data'); + + $this->assertTrue($metadata->isPublic($entity)); + $this->assertEquals('Overridden data', $metadata->getPropertyValue($entity)); + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php index d2c87db094c5..d48d6b1fe429 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php @@ -31,15 +31,6 @@ protected function tearDown() $this->builder = null; } - public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - public function testAddObjectInitializer() { $this->assertSame($this->builder, $this->builder->addObjectInitializer( @@ -96,15 +87,6 @@ public function testDisableAnnotationMapping() $this->assertSame($this->builder, $this->builder->disableAnnotationMapping()); } - public function testSetMetadataFactory() - { - set_error_handler(array($this, "deprecationErrorHandler")); - $this->assertSame($this->builder, $this->builder->setMetadataFactory( - $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface')) - ); - restore_error_handler(); - } - public function testSetMetadataCache() { $this->assertSame($this->builder, $this->builder->setMetadataCache( diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorContextTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorContextTest.php deleted file mode 100644 index d5540c3b1e41..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorContextTest.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests; - -use Symfony\Component\Validator\Validator; -use Symfony\Component\Validator\DefaultTranslator; -use Symfony\Component\Validator\Mapping\ClassMetadataFactoryAdapter; -use Symfony\Component\Validator\ValidatorContext; - -class ValidatorContextTest extends \PHPUnit_Framework_TestCase -{ - protected $context; - - protected function setUp() - { - set_error_handler(array($this, "deprecationErrorHandler")); - - $this->context = new ValidatorContext(); - } - - protected function tearDown() - { - restore_error_handler(); - - $this->context = null; - } - - public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - - public function testSetClassMetadataFactory() - { - $factory = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface'); - $result = $this->context->setClassMetadataFactory($factory); - - $this->assertSame($this->context, $result); - $this->assertSame($factory, $this->context->getClassMetadataFactory()); - } - - public function testSetConstraintValidatorFactory() - { - $factory = $this->getMock('Symfony\Component\Validator\ConstraintValidatorFactoryInterface'); - $result = $this->context->setConstraintValidatorFactory($factory); - - $this->assertSame($this->context, $result); - $this->assertSame($factory, $this->context->getConstraintValidatorFactory()); - } - - public function testGetValidator() - { - $metadataFactory = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface'); - $validatorFactory = $this->getMock('Symfony\Component\Validator\ConstraintValidatorFactoryInterface'); - - $validator = $this->context - ->setClassMetadataFactory($metadataFactory) - ->setConstraintValidatorFactory($validatorFactory) - ->getValidator(); - - $this->assertEquals(new Validator(new ClassMetadataFactoryAdapter($metadataFactory), $validatorFactory, new DefaultTranslator()), $validator); - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorFactoryTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorFactoryTest.php deleted file mode 100644 index 392f8073f9e2..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorFactoryTest.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests; - -use Doctrine\Common\Annotations\AnnotationReader; -use Symfony\Component\Validator\Mapping\ClassMetadataFactoryAdapter; -use Symfony\Component\Validator\Validator; -use Symfony\Component\Validator\DefaultTranslator; -use Symfony\Component\Validator\ValidatorContext; -use Symfony\Component\Validator\ValidatorFactory; -use Symfony\Component\Validator\ConstraintValidatorFactory; -use Symfony\Component\Validator\Mapping\ClassMetadataFactory; -use Symfony\Component\Validator\Mapping\Loader\XmlFilesLoader; -use Symfony\Component\Validator\Mapping\Loader\YamlFilesLoader; -use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader; -use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader; -use Symfony\Component\Validator\Mapping\Loader\LoaderChain; - -class ValidatorFactoryTest extends \PHPUnit_Framework_TestCase -{ - protected $defaultContext; - protected $factory; - - protected function setUp() - { - set_error_handler(array($this, "deprecationErrorHandler")); - - $this->defaultContext = new ValidatorContext(); - $this->factory = new ValidatorFactory($this->defaultContext); - } - - protected function tearDown() - { - restore_error_handler(); - - $this->defaultContext = null; - $this->factory = null; - } - - public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - - public function testOverrideClassMetadataFactory() - { - $factory1 = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface'); - $factory2 = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface'); - - $this->defaultContext->setClassMetadataFactory($factory1); - - $result = $this->factory->setClassMetadataFactory($factory2); - - $this->assertSame($factory1, $this->defaultContext->getClassMetadataFactory()); - $this->assertSame($factory2, $result->getClassMetadataFactory()); - } - - public function testOverrideConstraintValidatorFactory() - { - $factory1 = $this->getMock('Symfony\Component\Validator\ConstraintValidatorFactoryInterface'); - $factory2 = $this->getMock('Symfony\Component\Validator\ConstraintValidatorFactoryInterface'); - - $this->defaultContext->setConstraintValidatorFactory($factory1); - - $result = $this->factory->setConstraintValidatorFactory($factory2); - - $this->assertSame($factory1, $this->defaultContext->getConstraintValidatorFactory()); - $this->assertSame($factory2, $result->getConstraintValidatorFactory()); - } - - public function testGetValidator() - { - $metadataFactory = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface'); - $validatorFactory = $this->getMock('Symfony\Component\Validator\ConstraintValidatorFactoryInterface'); - - $this->defaultContext - ->setClassMetadataFactory($metadataFactory) - ->setConstraintValidatorFactory($validatorFactory); - - $validator = $this->factory->getValidator(); - - $this->assertEquals(new Validator(new ClassMetadataFactoryAdapter($metadataFactory), $validatorFactory, new DefaultTranslator()), $validator); - } - - public function testBuildDefaultFromAnnotationsWithCustomNamespaces() - { - if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) { - $this->markTestSkipped('Annotations is required for this test'); - } - $factory = ValidatorFactory::buildDefault(array(), true); - - $context = new ValidatorContext(); - $context - ->setClassMetadataFactory(new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()))) - ->setConstraintValidatorFactory(new ConstraintValidatorFactory()); - - $this->assertEquals(new ValidatorFactory($context), $factory); - } - - public function testBuildDefaultFromXml() - { - $path = __DIR__.'/Mapping/Loader/constraint-mapping.xml'; - $factory = ValidatorFactory::buildDefault(array($path), false); - - $context = new ValidatorContext(); - $context - ->setClassMetadataFactory(new ClassMetadataFactory(new XmlFilesLoader(array($path)))) - ->setConstraintValidatorFactory(new ConstraintValidatorFactory()); - - $this->assertEquals(new ValidatorFactory($context), $factory); - } - - public function testBuildDefaultFromYaml() - { - $path = __DIR__.'/Mapping/Loader/constraint-mapping.yml'; - $factory = ValidatorFactory::buildDefault(array($path), false); - - $context = new ValidatorContext(); - $context - ->setClassMetadataFactory(new ClassMetadataFactory(new YamlFilesLoader(array($path)))) - ->setConstraintValidatorFactory(new ConstraintValidatorFactory()); - - $this->assertEquals(new ValidatorFactory($context), $factory); - } - - public function testBuildDefaultFromStaticMethod() - { - $path = __DIR__.'/Mapping/Loader/constraint-mapping.yml'; - $factory = ValidatorFactory::buildDefault(array(), false, 'loadMetadata'); - - $context = new ValidatorContext(); - $context - ->setClassMetadataFactory(new ClassMetadataFactory(new StaticMethodLoader('loadMetadata'))) - ->setConstraintValidatorFactory(new ConstraintValidatorFactory()); - - $this->assertEquals(new ValidatorFactory($context), $factory); - } - - public function testBuildDefaultFromMultipleLoaders() - { - if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) { - $this->markTestSkipped('Annotations is required for this test'); - } - $xmlPath = __DIR__.'/Mapping/Loader/constraint-mapping.xml'; - $yamlPath = __DIR__.'/Mapping/Loader/constraint-mapping.yml'; - $factory = ValidatorFactory::buildDefault(array($xmlPath, $yamlPath), true, 'loadMetadata'); - - $chain = new LoaderChain(array( - new XmlFilesLoader(array($xmlPath)), - new YamlFilesLoader(array($yamlPath)), - new AnnotationLoader(new AnnotationReader()), - new StaticMethodLoader('loadMetadata'), - )); - - $context = new ValidatorContext(); - $context - ->setClassMetadataFactory(new ClassMetadataFactory($chain)) - ->setConstraintValidatorFactory(new ConstraintValidatorFactory()); - - $this->assertEquals(new ValidatorFactory($context), $factory); - } - - /** - * @expectedException \Symfony\Component\Validator\Exception\MappingException - */ - public function testBuildDefaultThrowsExceptionIfNoLoaderIsFound() - { - ValidatorFactory::buildDefault(); - } - - /** - * @expectedException \Symfony\Component\Validator\Exception\MappingException - */ - public function testBuildDefaultThrowsExceptionIfUnknownExtension() - { - ValidatorFactory::buildDefault(array( - __DIR__.'/Mapping/Loader/StaticMethodLoaderTest.php' - )); - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorTest.php index dbfa4f298d31..85a61e4816da 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorTest.php @@ -212,7 +212,7 @@ public function testValidateValue() 'Failed', 'Failed', array(), - '', + 'Bernhard', '', 'Bernhard' )); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitor.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitor.php index ad21eff74a66..ddff8adc6038 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitor.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitor.php @@ -63,13 +63,6 @@ class ValidationVisitor implements ValidationVisitorInterface, GlobalExecutionCo */ private $validatedObjects = array(); - /** - * @var GraphWalker - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. - */ - private $graphWalker; - /** * Creates a new validation visitor. * @@ -170,20 +163,6 @@ public function validate($value, $group, $propertyPath, $traverse = false, $deep } } - /** - * {@inheritdoc} - */ - public function getGraphWalker() - { - trigger_error('getGraphWalker() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); - - if (null === $this->graphWalker) { - $this->graphWalker = new GraphWalker($this, $this->metadataFactory, $this->translator, $this->translationDomain, $this->validatedObjects); - } - - return $this->graphWalker; - } - /** * {@inheritdoc} */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitorInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitorInterface.php index fb1022ffd6fc..e4163718b30d 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitorInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitorInterface.php @@ -77,14 +77,4 @@ public function validate($value, $group, $propertyPath, $traverse = false, $deep * @param string $propertyPath The current property path in the validation graph. */ public function visit(MetadataInterface $metadata, $value, $group, $propertyPath); - - /** - * Returns a graph walker with an alternative, deprecated API of the - * visitor. - * - * @return GraphWalker The graph walker. - * - * @deprecated Deprecated since version 2.2, to be removed in 2.3. - */ - public function getGraphWalker(); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Validator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Validator.php index 202e1e2f10dc..21abd59f03bd 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Validator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Validator.php @@ -87,7 +87,7 @@ public function validate($value, $groups = null, $traverse = false, $deep = fals $visitor = $this->createVisitor($value); foreach ($this->resolveGroups($groups) as $group) { - $visitor->validate($value, $group, ''); + $visitor->validate($value, $group, '', $traverse, $deep); } return $visitor->getViolations(); @@ -105,10 +105,10 @@ public function validateProperty($containingValue, $property, $groups = null) if (!$metadata instanceof PropertyMetadataContainerInterface) { $valueAsString = is_scalar($containingValue) - ? '"' . $containingValue . '"' - : 'the value of type ' . gettype($containingValue); + ? '"'.$containingValue.'"' + : 'the value of type '.gettype($containingValue); - throw new ValidatorException(sprintf('The metadata for ' . $valueAsString . ' does not support properties.')); + throw new ValidatorException(sprintf('The metadata for '.$valueAsString.' does not support properties.')); } foreach ($this->resolveGroups($groups) as $group) { @@ -136,10 +136,10 @@ public function validatePropertyValue($containingValue, $property, $value, $grou if (!$metadata instanceof PropertyMetadataContainerInterface) { $valueAsString = is_scalar($containingValue) - ? '"' . $containingValue . '"' - : 'the value of type ' . gettype($containingValue); + ? '"'.$containingValue.'"' + : 'the value of type '.gettype($containingValue); - throw new ValidatorException(sprintf('The metadata for ' . $valueAsString . ' does not support properties.')); + throw new ValidatorException(sprintf('The metadata for '.$valueAsString.' does not support properties.')); } foreach ($this->resolveGroups($groups) as $group) { @@ -160,7 +160,7 @@ public function validatePropertyValue($containingValue, $property, $value, $grou */ public function validateValue($value, $constraints, $groups = null) { - $context = new ExecutionContext($this->createVisitor(null), $this->translator, $this->translationDomain); + $context = new ExecutionContext($this->createVisitor($value), $this->translator, $this->translationDomain); $constraints = is_array($constraints) ? $constraints : array($constraints); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilder.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilder.php index 8937042d4410..a5bfc1fdf63c 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilder.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilder.php @@ -12,10 +12,8 @@ namespace Symfony\Component\Validator; use Symfony\Component\Validator\Mapping\ClassMetadataFactory; -use Symfony\Component\Validator\Mapping\ClassMetadataFactoryAdapter; use Symfony\Component\Validator\Exception\ValidatorException; use Symfony\Component\Validator\Mapping\Loader\LoaderChain; -use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface; use Symfony\Component\Validator\Mapping\Cache\CacheInterface; use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader; use Symfony\Component\Validator\Mapping\Loader\YamlFileLoader; @@ -225,17 +223,12 @@ public function disableAnnotationMapping() /** * {@inheritdoc} */ - public function setMetadataFactory($metadataFactory) + public function setMetadataFactory(MetadataFactoryInterface $metadataFactory) { if (count($this->xmlMappings) > 0 || count($this->yamlMappings) > 0 || count($this->methodMappings) > 0 || null !== $this->annotationReader) { throw new ValidatorException('You cannot set a custom metadata factory after adding custom mappings. You should do either of both.'); } - if ($metadataFactory instanceof ClassMetadataFactoryInterface - && !$metadataFactory instanceof MetadataFactoryInterface) { - $metadataFactory = new ClassMetadataFactoryAdapter($metadataFactory); - } - $this->metadataFactory = $metadataFactory; return $this; diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilderInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilderInterface.php index 18b96eac36fa..99f367b6aa1a 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilderInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilderInterface.php @@ -113,14 +113,11 @@ public function disableAnnotationMapping(); /** * Sets the class metadata factory used by the validator. * - * As of Symfony 2.3, the first parameter of this method will be typed - * against {@link MetadataFactoryInterface}. - * - * @param MetadataFactoryInterface|Mapping\ClassMetadataFactoryInterface $metadataFactory The metadata factory. + * @param MetadataFactoryInterface $metadataFactory The metadata factory. * * @return ValidatorBuilderInterface The builder object. */ - public function setMetadataFactory($metadataFactory); + public function setMetadataFactory(MetadataFactoryInterface $metadataFactory); /** * Sets the cache for caching class metadata. diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorContext.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorContext.php deleted file mode 100644 index c5e9f34e0d8d..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorContext.php +++ /dev/null @@ -1,124 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator; - -use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface; -use Symfony\Component\Validator\Mapping\ClassMetadataFactoryAdapter; - -/** - * Default implementation of ValidatorContextInterface - * - * @author Bernhard Schussek <bschussek@gmail.com> - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use - * {@link Validation::createValidatorBuilder()} instead. - */ -class ValidatorContext implements ValidatorContextInterface -{ - /** - * @var MetadataFactoryInterface - */ - private $metadataFactory; - - /** - * The class metadata factory used in the new validator - * @var ClassMetadataFactoryInterface - */ - protected $classMetadataFactory = null; - - /** - * The constraint validator factory used in the new validator - * @var ConstraintValidatorFactoryInterface - */ - protected $constraintValidatorFactory = null; - - /** - * {@inheritDoc} - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use - * {@link Validation::createValidatorBuilder()} instead. - */ - public function setClassMetadataFactory(ClassMetadataFactoryInterface $classMetadataFactory) - { - trigger_error('setClassMetadataFactory() is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidatorBuilder() instead.', E_USER_DEPRECATED); - - if ($classMetadataFactory instanceof MetadataFactoryInterface) { - $this->metadataFactory = $classMetadataFactory; - } else { - $this->metadataFactory = new ClassMetadataFactoryAdapter($classMetadataFactory); - } - - $this->classMetadataFactory = $classMetadataFactory; - - return $this; - } - - /** - * {@inheritDoc} - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use - * {@link Validation::createValidatorBuilder()} instead. - */ - public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $constraintValidatorFactory) - { - trigger_error('setConstraintValidatorFactory() is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidatorBuilder() instead.', E_USER_DEPRECATED); - - $this->constraintValidatorFactory = $constraintValidatorFactory; - - return $this; - } - - /** - * {@inheritDoc} - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use - * {@link Validation::createValidator()} instead. - */ - public function getValidator() - { - trigger_error('getValidator() is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidator() instead.', E_USER_DEPRECATED); - - return new Validator( - $this->metadataFactory, - $this->constraintValidatorFactory, - new DefaultTranslator() - ); - } - - /** - * Returns the class metadata factory used in the new validator - * - * @return ClassMetadataFactoryInterface The factory instance - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. - */ - public function getClassMetadataFactory() - { - trigger_error('getClassMetadataFactory() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); - - return $this->classMetadataFactory; - } - - /** - * Returns the constraint validator factory used in the new validator - * - * @return ConstraintValidatorFactoryInterface The factory instance - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. - */ - public function getConstraintValidatorFactory() - { - trigger_error('getConstraintValidatorFactory() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); - - return $this->constraintValidatorFactory; - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorContextInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorContextInterface.php deleted file mode 100644 index 73ce6b6c9969..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorContextInterface.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator; - -use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface; - -/** - * Stores settings for creating a new validator and creates validators - * - * The methods in this class are chainable, i.e. they return the context - * object itself. When you have finished configuring the new validator, call - * getValidator() to create the it. - * - * <code> - * $validator = $context - * ->setClassMetadataFactory($customFactory) - * ->getValidator(); - * </code> - * - * @author Bernhard Schussek <bschussek@gmail.com> - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use - * {@link Validation::createValidatorBuilder()} instead. - */ -interface ValidatorContextInterface -{ - /** - * Sets the class metadata factory used in the new validator - * - * @param ClassMetadataFactoryInterface $classMetadataFactory The factory instance - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use - * {@link Validation::createValidatorBuilder()} instead. - */ - public function setClassMetadataFactory(ClassMetadataFactoryInterface $classMetadataFactory); - - /** - * Sets the constraint validator factory used in the new validator - * - * @param ConstraintValidatorFactoryInterface $constraintValidatorFactory The factory instance - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use - * {@link Validation::createValidatorBuilder()} instead. - */ - public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $constraintValidatorFactory); - - /** - * Creates a new validator with the settings stored in this context - * - * @return ValidatorInterface The new validator - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use - * {@link Validation::createValidator()} instead. - */ - public function getValidator(); -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorFactory.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorFactory.php deleted file mode 100644 index 85522cd13eda..000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorFactory.php +++ /dev/null @@ -1,234 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator; - -use Doctrine\Common\Annotations\AnnotationReader; -use Symfony\Component\Validator\Exception\MappingException; -use Symfony\Component\Validator\Mapping\ClassMetadataFactory; -use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface; -use Symfony\Component\Validator\Mapping\Loader\XmlFilesLoader; -use Symfony\Component\Validator\Mapping\Loader\YamlFilesLoader; -use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader; -use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader; -use Symfony\Component\Validator\Mapping\Loader\LoaderChain; - -/** - * Creates and configures new validator objects - * - * Usually you will use the static method buildDefault() to initialize a - * factory with default configuration. To this method you can pass various - * parameters that configure where the validator mapping is found. If you - * don't pass a parameter, the mapping will be read from annotations. - * - * <code> - * // read from annotations only - * $factory = ValidatorFactory::buildDefault(); - * - * // read from XML and YAML, suppress annotations - * $factory = ValidatorFactory::buildDefault(array( - * '/path/to/mapping.xml', - * '/path/to/other/mapping.yml', - * ), false); - * </code> - * - * You then have to call getValidator() to create new validators. - * - * <code> - * $validator = $factory->getValidator(); - * </code> - * - * When manually constructing a factory, the default configuration of the - * validators can be passed to the constructor as a ValidatorContextInterface - * object. - * - * <code> - * $defaultContext = new ValidatorContext(); - * $defaultContext->setClassMetadataFactory($metadataFactory); - * $defaultContext->setConstraintValidatorFactory($validatorFactory); - * $factory = new ValidatorFactory($defaultContext); - * - * $form = $factory->getValidator(); - * </code> - * - * You can also override the default configuration by calling any of the - * methods in this class. These methods return a ValidatorContextInterface object - * on which you can override further settings or call getValidator() to create - * a form. - * - * <code> - * $form = $factory - * ->setClassMetadataFactory($customFactory); - * ->getValidator(); - * </code> - * - * ValidatorFactory instances should be cached and reused in your application. - * - * @author Bernhard Schussek <bschussek@gmail.com> - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use - * {@link Validation::createValidatorBuilder()} instead. - */ -class ValidatorFactory implements ValidatorContextInterface -{ - /** - * Holds the context with the default configuration - * @var ValidatorContextInterface - */ - protected $defaultContext; - - /** - * Builds a validator factory with the default mapping loaders - * - * @param array $mappingFiles A list of XML or YAML file names - * where mapping information can be - * found. Can be empty. - * @param Boolean $annotations Whether to use annotations for - * retrieving mapping information - * @param string $staticMethod The name of the static method to - * use, if static method loading should - * be enabled - * - * @return ValidatorFactory The validator factory. - * - * @throws MappingException If any of the files in $mappingFiles - * has neither the extension ".xml" nor - * ".yml" nor ".yaml" - * @throws \RuntimeException If annotations are not supported. - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use - * {@link Validation::createValidatorBuilder()} instead. - */ - public static function buildDefault(array $mappingFiles = array(), $annotations = false, $staticMethod = null) - { - trigger_error('buildDefault() is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidatorBuilder() instead.', E_USER_DEPRECATED); - - $xmlMappingFiles = array(); - $yamlMappingFiles = array(); - $loaders = array(); - $context = new ValidatorContext(); - - foreach ($mappingFiles as $file) { - $extension = pathinfo($file, PATHINFO_EXTENSION); - - if ($extension === 'xml') { - $xmlMappingFiles[] = $file; - } elseif ($extension === 'yaml' || $extension === 'yml') { - $yamlMappingFiles[] = $file; - } else { - throw new MappingException('The only supported mapping file formats are XML and YAML'); - } - } - - if (count($xmlMappingFiles) > 0) { - $loaders[] = new XmlFilesLoader($xmlMappingFiles); - } - - if (count($yamlMappingFiles) > 0) { - $loaders[] = new YamlFilesLoader($yamlMappingFiles); - } - - if ($annotations) { - if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) { - throw new \RuntimeException('Requested a ValidatorFactory with an AnnotationLoader, but the AnnotationReader was not found. You should add Doctrine Common to your project.'); - } - - $loaders[] = new AnnotationLoader(new AnnotationReader()); - } - - if ($staticMethod) { - $loaders[] = new StaticMethodLoader($staticMethod); - } - - if (count($loaders) > 1) { - $loader = new LoaderChain($loaders); - } elseif (count($loaders) === 1) { - $loader = $loaders[0]; - } else { - throw new MappingException('No mapping loader was found for the given parameters'); - } - - $context->setClassMetadataFactory(new ClassMetadataFactory($loader)); - $context->setConstraintValidatorFactory(new ConstraintValidatorFactory()); - - return new static($context); - } - - /** - * Sets the given context as default context - * - * @param ValidatorContextInterface $defaultContext A preconfigured context - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use - * {@link Validation::createValidatorBuilder()} instead. - */ - public function __construct(ValidatorContextInterface $defaultContext = null) - { - trigger_error('ValidatorFactory is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidatorBuilder() instead.', E_USER_DEPRECATED); - - $this->defaultContext = null === $defaultContext ? new ValidatorContext() : $defaultContext; - } - - /** - * Overrides the class metadata factory of the default context and returns - * the new context - * - * @param ClassMetadataFactoryInterface $metadataFactory The new factory instance - * - * @return ValidatorContextInterface The preconfigured form context - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use - * {@link Validation::createValidatorBuilder()} instead. - */ - public function setClassMetadataFactory(ClassMetadataFactoryInterface $metadataFactory) - { - trigger_error('setClassMetadataFactory() is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidatorBuilder() instead.', E_USER_DEPRECATED); - - $context = clone $this->defaultContext; - - return $context->setClassMetadataFactory($metadataFactory); - } - - /** - * Overrides the constraint validator factory of the default context and - * returns the new context - * - * @param ClassMetadataFactoryInterface $validatorFactory The new factory instance - * - * @return ValidatorContextInterface The preconfigured form context - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use - * {@link Validation::createValidatorBuilder()} instead. - */ - public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory) - { - trigger_error('setConstraintValidatorFactory() is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidatorBuilder() instead.', E_USER_DEPRECATED); - - $context = clone $this->defaultContext; - - return $context->setConstraintValidatorFactory($validatorFactory); - } - - /** - * Creates a new validator with the settings stored in the default context - * - * @return ValidatorInterface The new validator - * - * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use - * {@link Validation::createValidator()} instead. - */ - public function getValidator() - { - trigger_error('getValidator() is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidator() instead.', E_USER_DEPRECATED); - - return $this->defaultContext->getValidator(); - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/composer.json b/core/vendor/symfony/validator/Symfony/Component/Validator/composer.json index ca8c501267e8..951ef01526e9 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/composer.json +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/composer.json @@ -21,16 +21,16 @@ }, "require-dev": { "symfony/http-foundation": "~2.1", - "symfony/locale": "~2.0", + "symfony/intl": "~2.3", "symfony/yaml": "~2.0", - "symfony/config": ">=2.2,<2.3-dev" + "symfony/config": "~2.2" }, "suggest": { - "doctrine/common": "~2.2", - "symfony/http-foundation": "2.2.*", - "symfony/locale": "2.2.*", - "symfony/yaml": "2.2.*", - "symfony/config": "2.2.*" + "doctrine/common": "", + "symfony/http-foundation": "", + "symfony/intl": "", + "symfony/yaml": "", + "symfony/config": "" }, "autoload": { "psr-0": { "Symfony\\Component\\Validator\\": "" } @@ -39,7 +39,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php index bafceb06c887..680b50349c92 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php @@ -102,7 +102,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $parser->refs =& $this->refs; $block = $values['value']; - if (!$this->isNextLineIndented()) { + if ($this->isNextLineIndented()) { $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2); } @@ -174,7 +174,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = // hash } elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { // if next line is less indented or equal, then it means that the current value is null - if ($this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) { + if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) { $data[$key] = null; } else { $c = $this->getRealCurrentLineNb() + 1; @@ -365,7 +365,9 @@ private function moveToPreviousLine() /** * Parses a YAML value. * - * @param string $value A YAML value + * @param string $value A YAML value + * @param Boolean $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise + * @param Boolean $objectSupport True if object support is enabled, false otherwise * * @return mixed A PHP value * @@ -419,6 +421,18 @@ private function parseFoldedScalar($separator, $indicator = '', $indentation = 0 return ''; } + $isCurrentLineBlank = $this->isCurrentLineBlank(); + $text = ''; + + // leading blank lines are consumed before determining indentation + while ($notEOF && $isCurrentLineBlank) { + // newline only if not EOF + if ($notEOF = $this->moveToNextLine()) { + $text .= "\n"; + $isCurrentLineBlank = $this->isCurrentLineBlank(); + } + } + // determine indentation if not specified if (0 === $indentation) { if (preg_match('/^ +/', $this->currentLine, $matches)) { @@ -426,11 +440,9 @@ private function parseFoldedScalar($separator, $indicator = '', $indentation = 0 } } - $text = ''; if ($indentation > 0) { $pattern = sprintf('/^ {%d}(.*)$/', $indentation); - $isCurrentLineBlank = $this->isCurrentLineBlank(); while ( $notEOF && ( $isCurrentLineBlank || @@ -482,18 +494,18 @@ private function parseFoldedScalar($separator, $indicator = '', $indentation = 0 private function isNextLineIndented() { $currentIndentation = $this->getCurrentLineIndentation(); - $notEOF = $this->moveToNextLine(); + $EOF = !$this->moveToNextLine(); - while ($notEOF && $this->isCurrentLineEmpty()) { - $notEOF = $this->moveToNextLine(); + while (!$EOF && $this->isCurrentLineEmpty()) { + $EOF = !$this->moveToNextLine(); } - if (false === $notEOF) { + if ($EOF) { return false; } $ret = false; - if ($this->getCurrentLineIndentation() <= $currentIndentation) { + if ($this->getCurrentLineIndentation() > $currentIndentation) { $ret = true; } diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php index 04e9d4df8098..a93b91612dca 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php @@ -49,7 +49,7 @@ public function testDumpNumericValueWithLocale() $required_locales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252'); if (false === setlocale(LC_ALL, $required_locales)) { - $this->markTestSkipped('Could not set any of required locales: ' . implode(", ", $required_locales)); + $this->markTestSkipped('Could not set any of required locales: '.implode(", ", $required_locales)); } $this->assertEquals('1.2', Inline::dump(1.2)); diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php index ca69aec153a6..a8d28b9131de 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php @@ -396,6 +396,27 @@ public function testBlockChomping($expected, $yaml) $this->assertSame($expected, $this->parser->parse($yaml)); } + /** + * Regression test for issue #7989. + * + * @see https://github.com/symfony/symfony/issues/7989 + */ + public function testBlockLiteralWithLeadingNewlines() + { + $yaml = <<<'EOF' +foo: |- + + + bar + +EOF; + $expected = array( + 'foo' => "\n\nbar" + ); + + $this->assertSame($expected, $this->parser->parse($yaml)); + } + public function testObjectSupportEnabled() { $input = <<<EOF @@ -492,6 +513,15 @@ public function testMappingInASequence() EOF ); } + + public function testEmptyValue() + { + $input = <<<EOF +hash: +EOF; + + $this->assertEquals(array('hash' => null), Yaml::parse($input)); + } } class B diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/YamlTest.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/YamlTest.php index b1a9ba08c1f6..633978d63bd5 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/YamlTest.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/YamlTest.php @@ -15,7 +15,6 @@ class YamlTest extends \PHPUnit_Framework_TestCase { - public function testParseAndDump() { $data = array('lorem' => 'ipsum', 'dolor' => 'sit'); @@ -29,13 +28,4 @@ public function testParseAndDump() $parsedByContents = Yaml::parse($contents); $this->assertEquals($parsedByFilename, $parsedByContents); } - - public function testEmbededPhp() - { - $filename = __DIR__.'/Fixtures/embededPhp.yml'; - Yaml::enablePhpParsing(); - $parsed = Yaml::parse($filename); - $this->assertEquals(array('value' => 6), $parsed); - } - } diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php index adc99c471e4d..c98f6ecdd96e 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php @@ -22,53 +22,6 @@ */ class Yaml { - /** - * Be warned that PHP support will be removed in Symfony 2.3. - * - * @deprecated Deprecated since version 2.0, to be removed in 2.3. - */ - public static $enablePhpParsing = false; - - /** - * Enables PHP support when parsing YAML files. - * - * Be warned that PHP support will be removed in Symfony 2.3. - * - * @deprecated Deprecated since version 2.0, to be removed in 2.3. - */ - public static function enablePhpParsing() - { - self::$enablePhpParsing = true; - } - - /** - * Sets the PHP support flag when parsing YAML files. - * - * Be warned that PHP support will be removed in Symfony 2.3. - * - * @param Boolean $boolean true if PHP parsing support is enabled, false otherwise - * - * @deprecated Deprecated since version 2.0, to be removed in 2.3. - */ - public static function setPhpParsing($boolean) - { - self::$enablePhpParsing = (Boolean) $boolean; - } - - /** - * Checks if PHP support is enabled when parsing YAML files. - * - * Be warned that PHP support will be removed in Symfony 2.3. - * - * @return Boolean true if PHP parsing support is enabled, false otherwise - * - * @deprecated Deprecated since version 2.0, to be removed in 2.3. - */ - public static function supportsPhpParsing() - { - return self::$enablePhpParsing; - } - /** * Parses YAML into a PHP array. * @@ -85,7 +38,9 @@ public static function supportsPhpParsing() * you must validate the input before calling this method. Passing a file * as an input is a deprecated feature and will be removed in 3.0. * - * @param string $input Path to a YAML file or a string containing YAML + * @param string $input Path to a YAML file or a string containing YAML + * @param Boolean $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise + * @param Boolean $objectSupport True if object support is enabled, false otherwise * * @return array The YAML converted to a PHP array * @@ -103,21 +58,7 @@ public static function parse($input, $exceptionOnInvalidType = false, $objectSup } $file = $input; - if (self::$enablePhpParsing) { - ob_start(); - $retval = include($file); - $content = ob_get_clean(); - - // if an array is returned by the config file assume it's in plain php form else in YAML - $input = is_array($retval) ? $retval : $content; - - // if an array is returned by the config file assume it's in plain php form else in YAML - if (is_array($input)) { - return $input; - } - } else { - $input = file_get_contents($file); - } + $input = file_get_contents($file); } $yaml = new Parser(); diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json b/core/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json index e04dabf3fc22..1a009c16d6a2 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } -- GitLab