diff --git a/src/Symfony/Bridge/Doctrine/README.md b/src/Symfony/Bridge/Doctrine/README.md index 3dabc3cd6d..46d897d061 100644 --- a/src/Symfony/Bridge/Doctrine/README.md +++ b/src/Symfony/Bridge/Doctrine/README.md @@ -7,8 +7,7 @@ various Symfony components. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Bridge/Doctrine/ - $ composer install - $ phpunit + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Bridge/Monolog/README.md b/src/Symfony/Bridge/Monolog/README.md index b0d91ca4f4..2d19b3e27c 100644 --- a/src/Symfony/Bridge/Monolog/README.md +++ b/src/Symfony/Bridge/Monolog/README.md @@ -6,8 +6,7 @@ Provides integration for Monolog with various Symfony components. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Bridge/Monolog/ - $ composer install - $ phpunit + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Bridge/Propel1/README.md b/src/Symfony/Bridge/Propel1/README.md new file mode 100644 index 0000000000..41286745ab --- /dev/null +++ b/src/Symfony/Bridge/Propel1/README.md @@ -0,0 +1,12 @@ +Propel Bridge +============= + +Provides integration for Propel with various Symfony components. + +Resources +--------- + + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Bridge/ProxyManager/README.md b/src/Symfony/Bridge/ProxyManager/README.md index 35d41998b8..38d3d69645 100644 --- a/src/Symfony/Bridge/ProxyManager/README.md +++ b/src/Symfony/Bridge/ProxyManager/README.md @@ -6,10 +6,9 @@ Provides integration for [ProxyManager][1] with various Symfony components. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Bridge/ProxyManager/ - $ composer install - $ phpunit + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) [1]: https://github.com/Ocramius/ProxyManager diff --git a/src/Symfony/Bridge/Twig/README.md b/src/Symfony/Bridge/Twig/README.md index 1f92af944f..eb084147c3 100644 --- a/src/Symfony/Bridge/Twig/README.md +++ b/src/Symfony/Bridge/Twig/README.md @@ -7,9 +7,7 @@ Symfony components. Resources --------- -If you want to run the unit tests, install dev dependencies before -running PHPUnit: - - $ cd path/to/Symfony/Bridge/Twig/ - $ composer install - $ phpunit + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php index 92fb94419d..c50541fa27 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php @@ -55,7 +55,7 @@ class TemplateNameParser extends BaseTemplateNameParser throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name)); } - if (!preg_match('/^(?:([^:]*):)?(?:([^:]*):)?(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches)) { + if (!preg_match('/^(?:([^:]*):([^:]*):)?(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches) || $this->isAbsolutePath($name) || 0 === strpos($name, '@')) { return parent::parse($name); } @@ -71,4 +71,9 @@ class TemplateNameParser extends BaseTemplateNameParser return $this->cache[$name] = $template; } + + private function isAbsolutePath($file) + { + return (bool) preg_match('#^(?:/|[a-zA-Z]:)#', $file); + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php index 4ff824bf7c..479475732c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php @@ -66,6 +66,12 @@ class TemplateNameParserTest extends TestCase array('::index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')), array('index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')), array('FooBundle:Post:foo.bar.index.html.php', 'FooBundle:Post:foo.bar.index.html.php', '@FooBundle/Resources/views/Post/foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')), + array('@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', new BaseTemplateReference('@FooBundle/Resources/views/layout.html.twig', 'twig')), + array('@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', new BaseTemplateReference('@FooBundle/Foo/layout.html.twig', 'twig')), + array('/path/to/section/index.html.php', '/path/to/section/index.html.php', '/path/to/section/index.html.php', new BaseTemplateReference('/path/to/section/index.html.php', 'php')), + array('C:\\path\\to\\section\\name.html.php', 'C:path/to/section/name.html.php', 'C:path/to/section/name.html.php', new BaseTemplateReference('C:path/to/section/name.html.php', 'php')), + array('C:\\path\\to\\section\\name:foo.html.php', 'C:path/to/section/name:foo.html.php', 'C:path/to/section/name:foo.html.php', new BaseTemplateReference('C:path/to/section/name:foo.html.php', 'php')), + array('\\path\\to\\section\\name.html.php', '/path/to/section/name.html.php', '/path/to/section/name.html.php', new BaseTemplateReference('/path/to/section/name.html.php', 'php')), array('/path/to/section/name.php', '/path/to/section/name.php', '/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')), array('name.twig', 'name.twig', 'name.twig', new BaseTemplateReference('name.twig', 'twig')), array('name', 'name', 'name', new BaseTemplateReference('name')), diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index 769976b304..4e0bef365e 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -76,19 +76,18 @@ class FilesystemLoader extends \Twig_Loader_Filesystem try { $file = parent::findTemplate($logicalName); } catch (\Twig_Error_Loader $e) { - $previous = $e; + $twigLoaderException = $e; // for BC try { $template = $this->parser->parse($template); $file = $this->locator->locate($template); } catch (\Exception $e) { - $previous = $e; } } if (false === $file || null === $file) { - throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $logicalName), -1, null, $previous); + throw $twigLoaderException; } return $this->cache[$logicalName] = $file; diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php index c6d5e277a2..0ee259fb7b 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php @@ -98,4 +98,21 @@ class FilesystemLoaderTest extends TestCase $loader = new FilesystemLoader($locator, $parser); $loader->getCacheKey('name.format.engine'); } + + /** + * @expectedException \Twig_Error_Loader + * @expectedExceptionMessageRegExp /Unable to find template "name\.format\.engine" \(looked into: .*Tests.Loader.\.\..DependencyInjection.Fixtures.Resources.views\)/ + */ + public function testTwigErrorIfTemplateDoesNotExist() + { + $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); + $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); + + $loader = new FilesystemLoader($locator, $parser); + $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views'); + + $method = new \ReflectionMethod('Symfony\Bundle\TwigBundle\Loader\FilesystemLoader', 'findTemplate'); + $method->setAccessible(true); + $method->invoke($loader, 'name.format.engine'); + } } diff --git a/src/Symfony/Component/BrowserKit/README.md b/src/Symfony/Component/BrowserKit/README.md index 5600fe2e1f..a0083ac5bd 100644 --- a/src/Symfony/Component/BrowserKit/README.md +++ b/src/Symfony/Component/BrowserKit/README.md @@ -1,23 +1,14 @@ BrowserKit Component ==================== -BrowserKit simulates the behavior of a web browser. - -The component only provides an abstract client and does not provide any -"default" backend for the HTTP layer. +The BrowserKit component simulates the behavior of a web browser, allowing you +to make requests, click on links and submit forms programmatically. Resources --------- -For a simple implementation of a browser based on an HTTP layer, have a look -at [Goutte](https://github.com/FriendsOfPHP/Goutte). - -For an implementation based on HttpKernelInterface, have a look at the -[Client](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Client.php) -provided by the HttpKernel component. - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/BrowserKit/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/browser_kit/introduction.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/ClassLoader/README.md b/src/Symfony/Component/ClassLoader/README.md index 0d2955dc97..d61992b6a8 100644 --- a/src/Symfony/Component/ClassLoader/README.md +++ b/src/Symfony/Component/ClassLoader/README.md @@ -1,85 +1,14 @@ ClassLoader Component ===================== -ClassLoader loads your project classes automatically if they follow some -standard PHP conventions. - -The ClassLoader object is able to autoload classes that implement the PSR-0 -standard or the PEAR naming convention. - -First, register the autoloader: - -```php -require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php'; - -use Symfony\Component\ClassLoader\ClassLoader; - -$loader = new ClassLoader(); -$loader->register(); -``` - -Then, register some namespaces with the `addPrefix()` method: - -```php -$loader->addPrefix('Symfony', __DIR__.'/src'); -$loader->addPrefix('Monolog', __DIR__.'/vendor/monolog/src'); -``` - -The `addPrefix()` method takes a namespace prefix and a path where to -look for the classes as arguments. - -You can also register a sub-namespaces: - -```php -$loader->addPrefix('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib'); -``` - -The order of registration is significant and the first registered namespace -takes precedence over later registered one. - -You can also register more than one path for a given namespace: - -```php -$loader->addPrefix('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src')); -``` - -Alternatively, you can use the `addPrefixes()` method to register more -than one namespace at once: - -```php -$loader->addPrefixes(array( - 'Symfony' => array(__DIR__.'/src', __DIR__.'/symfony/src'), - 'Doctrine\\Common' => __DIR__.'/vendor/doctrine-common/lib', - 'Doctrine' => __DIR__.'/vendor/doctrine/lib', - 'Monolog' => __DIR__.'/vendor/monolog/src', -)); -``` - -For better performance, you can use the APC class loader: - -```php -require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php'; -require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcClassLoader.php'; - -use Symfony\Component\ClassLoader\ClassLoader; -use Symfony\Component\ClassLoader\ApcClassLoader; - -$loader = new ClassLoader(); -$loader->addPrefix('Symfony', __DIR__.'/src'); - -$loader = new ApcClassLoader('apc.prefix.', $loader); -$loader->register(); -``` - -Furthermore, the component provides tools to aggregate classes into a single -file, which is especially useful to improve performance on servers that do not -provide byte caches. +The ClassLoader component provides tools to autoload your classes and cache +their locations for performance. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/ClassLoader/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/class_loader/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Config/README.md b/src/Symfony/Component/Config/README.md index 690d7d74f9..bf400da196 100644 --- a/src/Symfony/Component/Config/README.md +++ b/src/Symfony/Component/Config/README.md @@ -1,17 +1,15 @@ Config Component ================ -Config provides the infrastructure for loading configurations from different -data sources and optionally monitoring these data sources for changes. There -are additional tools for validating, normalizing and handling of defaults that -can optionally be used to convert from different formats to arrays. +The Config component provides several classes to help you find, load, combine, +autofill and validate configuration values of any kind, whatever their source +may be (YAML, XML, INI files, or for instance a database). Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Config/ - $ composer install - $ phpunit - + * [Documentation](https://symfony.com/doc/current/components/config/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Console/README.md b/src/Symfony/Component/Console/README.md index 25f700c8d4..664a37c0ee 100644 --- a/src/Symfony/Component/Console/README.md +++ b/src/Symfony/Component/Console/README.md @@ -1,67 +1,20 @@ Console Component ================= -Console eases the creation of beautiful and testable command line interfaces. - -The Application object manages the CLI application: - -```php -use Symfony\Component\Console\Application; - -$console = new Application(); -$console->run(); -``` - -The ``run()`` method parses the arguments and options passed on the command -line and executes the right command. - -Registering a new command can easily be done via the ``register()`` method, -which returns a ``Command`` instance: - -```php -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; - -$console - ->register('ls') - ->setDefinition(array( - new InputArgument('dir', InputArgument::REQUIRED, 'Directory name'), - )) - ->setDescription('Displays the files in the given directory') - ->setCode(function (InputInterface $input, OutputInterface $output) { - $dir = $input->getArgument('dir'); - - $output->writeln(sprintf('Dir listing for %s', $dir)); - }) -; -``` - -You can also register new commands via classes. - -The component provides a lot of features like output coloring, input and -output abstractions (so that you can easily unit-test your commands), -validation, automatic help messages, ... - -Tests ------ - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Console/ - $ composer install - $ phpunit - -Third Party ------------ - -`Resources/bin/hiddeninput.exe` is a third party binary provided within this -component. Find sources and license at https://github.com/Seldaek/hidden-input. +The Console component eases the creation of beautiful and testable command line +interfaces. Resources --------- -[The Console Component](https://symfony.com/doc/current/components/console.html) + * [Documentation](https://symfony.com/doc/current/components/console/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) -[How to create a Console Command](https://symfony.com/doc/current/cookbook/console/console_command.html) +Credits +------- + +`Resources/bin/hiddeninput.exe` is a third party binary provided within this +component. Find sources and license at https://github.com/Seldaek/hidden-input. diff --git a/src/Symfony/Component/CssSelector/README.md b/src/Symfony/Component/CssSelector/README.md index ffe6c890f6..7c4c411635 100644 --- a/src/Symfony/Component/CssSelector/README.md +++ b/src/Symfony/Component/CssSelector/README.md @@ -1,47 +1,20 @@ CssSelector Component ===================== -CssSelector converts CSS selectors to XPath expressions. - -The component only goal is to convert CSS selectors to their XPath -equivalents: - -```php -use Symfony\Component\CssSelector\CssSelector; - -print CssSelector::toXPath('div.item > h4 > a'); -``` - -HTML and XML are different --------------------------- - -The `CssSelector` component comes with an `HTML` extension which is enabled by -default. If you need to use this component with `XML` documents, you have to -disable this `HTML` extension. That's because, `HTML` tag & attribute names -are always lower-cased, but case-sensitive in `XML`: - -```php -// disable `HTML` extension: -CssSelector::disableHtmlExtension(); - -// re-enable `HTML` extension: -CssSelector::enableHtmlExtension(); -``` - -When the `HTML` extension is enabled, tag names are lower-cased, attribute -names are lower-cased, the following extra pseudo-classes are supported: -`checked`, `link`, `disabled`, `enabled`, `selected`, `invalid`, `hover`, -`visited`, and the `lang()` function is also added. +The CssSelector component converts CSS selectors to XPath expressions. Resources --------- + * [Documentation](https://symfony.com/doc/current/components/css_selector.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) + +Credits +------- + This component is a port of the Python cssselect library [v0.7.1](https://github.com/SimonSapin/cssselect/releases/tag/v0.7.1), which is distributed under the BSD license. - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/CssSelector/ - $ composer install - $ phpunit diff --git a/src/Symfony/Component/Debug/README.md b/src/Symfony/Component/Debug/README.md index 82c6e30322..a1d16175c1 100644 --- a/src/Symfony/Component/Debug/README.md +++ b/src/Symfony/Component/Debug/README.md @@ -1,42 +1,13 @@ Debug Component =============== -Debug provides tools to make debugging easier. - -Enabling all debug tools is as easy as calling the `enable()` method on the -main `Debug` class: - -```php -use Symfony\Component\Debug\Debug; - -Debug::enable(); -``` - -You can also use the tools individually: - -```php -use Symfony\Component\Debug\DebugClassLoader; -use Symfony\Component\Debug\ErrorHandler; -use Symfony\Component\Debug\ExceptionHandler; - -if ('cli' !== php_sapi_name()) { - ini_set('display_errors', 0); - ExceptionHandler::register(); -} elseif (!ini_get('log_errors') || ini_get('error_log')) { - ini_set('display_errors', 1); -} -ErrorHandler::register(); -DebugClassLoader::enable(); -``` - -This component can optionally take advantage of the features of the HttpKernel -and HttpFoundation components. +The Debug component provides tools to ease debugging PHP code. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Debug/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/debug/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/DependencyInjection/README.md b/src/Symfony/Component/DependencyInjection/README.md index 19a1142ae2..932647f94a 100644 --- a/src/Symfony/Component/DependencyInjection/README.md +++ b/src/Symfony/Component/DependencyInjection/README.md @@ -1,80 +1,14 @@ DependencyInjection Component ============================= -DependencyInjection manages your services via a robust and flexible Dependency -Injection Container. - -Here is a simple example that shows how to register services and parameters: - -```php -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; - -$sc = new ContainerBuilder(); -$sc - ->register('foo', '%foo.class%') - ->addArgument(new Reference('bar')) -; -$sc->setParameter('foo.class', 'Foo'); - -$sc->get('foo'); -``` - -Method Calls (Setter Injection): - -```php -$sc = new ContainerBuilder(); - -$sc - ->register('bar', '%bar.class%') - ->addMethodCall('setFoo', array(new Reference('foo'))) -; -$sc->setParameter('bar.class', 'Bar'); - -$sc->get('bar'); -``` - -Factory Class: - -If your service is retrieved by calling a static method: - -```php -$sc = new ContainerBuilder(); - -$sc - ->register('bar', '%bar.class%') - ->setFactory(array('%bar.class%', 'getInstance')) - ->addArgument('Aarrg!!!') -; -$sc->setParameter('bar.class', 'Bar'); - -$sc->get('bar'); -``` - -File Include: - -For some services, especially those that are difficult or impossible to -autoload, you may need the container to include a file before -instantiating your class. - -```php -$sc = new ContainerBuilder(); - -$sc - ->register('bar', '%bar.class%') - ->setFile('/path/to/file') - ->addArgument('Aarrg!!!') -; -$sc->setParameter('bar.class', 'Bar'); - -$sc->get('bar'); -``` +The DependencyInjection component allows you to standardize and centralize the +way objects are constructed in your application. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/DependencyInjection/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/dependency_injection/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/DomCrawler/README.md b/src/Symfony/Component/DomCrawler/README.md index d2c8de5da4..5fad2e27ad 100644 --- a/src/Symfony/Component/DomCrawler/README.md +++ b/src/Symfony/Component/DomCrawler/README.md @@ -1,36 +1,13 @@ DomCrawler Component ==================== -DomCrawler eases DOM navigation for HTML and XML documents. - -If you are familiar with jQuery, DomCrawler is a PHP equivalent: - -```php -use Symfony\Component\DomCrawler\Crawler; - -$crawler = new Crawler(); -$crawler->addContent('

Hello World!

'); - -print $crawler->filterXPath('descendant-or-self::body/p')->text(); -``` - -If you are also using the CssSelector component, you can use CSS Selectors -instead of XPath expressions: - -```php -use Symfony\Component\DomCrawler\Crawler; - -$crawler = new Crawler(); -$crawler->addContent('

Hello World!

'); - -print $crawler->filter('body > p')->text(); -``` +The DomCrawler component eases DOM navigation for HTML and XML documents. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/DomCrawler/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/dom_crawler.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/EventDispatcher/README.md b/src/Symfony/Component/EventDispatcher/README.md index 8031f4dd3f..185c3fecf8 100644 --- a/src/Symfony/Component/EventDispatcher/README.md +++ b/src/Symfony/Component/EventDispatcher/README.md @@ -1,27 +1,15 @@ EventDispatcher Component ========================= -The Symfony EventDispatcher component implements the Mediator pattern in a -simple and effective way to make your projects truly extensible. - -```php -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\Event; - -$dispatcher = new EventDispatcher(); - -$dispatcher->addListener('event_name', function (Event $event) { - // ... -}); - -$dispatcher->dispatch('event_name'); -``` +The EventDispatcher component provides tools that allow your application +components to communicate with each other by dispatching events and listening to +them. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/EventDispatcher/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/event_dispatcher/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Filesystem/README.md b/src/Symfony/Component/Filesystem/README.md index df09f93dce..877ab3543f 100644 --- a/src/Symfony/Component/Filesystem/README.md +++ b/src/Symfony/Component/Filesystem/README.md @@ -1,47 +1,13 @@ Filesystem Component ==================== -Filesystem provides basic utility to manipulate the file system: - -```php -copy($originFile, $targetFile, $override = false); - -$filesystem->mkdir($dirs, $mode = 0777); - -$filesystem->touch($files, $time = null, $atime = null); - -$filesystem->remove($files); - -$filesystem->exists($files); - -$filesystem->chmod($files, $mode, $umask = 0000, $recursive = false); - -$filesystem->chown($files, $user, $recursive = false); - -$filesystem->chgrp($files, $group, $recursive = false); - -$filesystem->rename($origin, $target); - -$filesystem->symlink($originDir, $targetDir, $copyOnWindows = false); - -$filesystem->makePathRelative($endPath, $startPath); - -$filesystem->mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array()); - -$filesystem->isAbsolutePath($file); -``` +The Filesystem component provides basic utilities for the filesystem. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Filesystem/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/filesystem/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Finder/README.md b/src/Symfony/Component/Finder/README.md index 4fb1eca007..0b19c75257 100644 --- a/src/Symfony/Component/Finder/README.md +++ b/src/Symfony/Component/Finder/README.md @@ -1,53 +1,14 @@ Finder Component ================ -Finder finds files and directories via an intuitive fluent interface. - -```php -use Symfony\Component\Finder\Finder; - -$finder = new Finder(); - -$iterator = $finder - ->files() - ->name('*.php') - ->depth(0) - ->size('>= 1K') - ->in(__DIR__); - -foreach ($iterator as $file) { - print $file->getRealpath()."\n"; -} -``` - -The iterator returns instances of [Symfony\Component\Finder\SplFileInfo\SplFileInfo][1]. -Besides the build-in methods inherited from [\SplFileInfo][2] (`getPerms()`, `getSize()`, ...), -you can also use `getRelativePath()` and `getRelativePathname()`. Read the -[official documentation][3] for more information. - -But you can also use it to find files stored remotely like in this example where -we are looking for files on Amazon S3: - -```php -$s3 = new \Zend_Service_Amazon_S3($key, $secret); -$s3->registerStreamWrapper("s3"); - -$finder = new Finder(); -$finder->name('photos*')->size('< 100K')->date('since 1 hour ago'); -foreach ($finder->in('s3://bucket-name') as $file) { - print $file->getFilename()."\n"; -} -``` +The Finder component finds files and directories via an intuitive fluent +interface. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Finder/ - $ composer install - $ phpunit - -[1]: http://api.symfony.com/2.5/Symfony/Component/Finder/SplFileInfo.html -[2]: http://php.net/splfileinfo -[3]: https://symfony.com/doc/current/components/finder.html#usage + * [Documentation](https://symfony.com/doc/current/components/finder.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Form/README.md b/src/Symfony/Component/Form/README.md index 8016f20ef4..3fe6f8bbf3 100644 --- a/src/Symfony/Component/Form/README.md +++ b/src/Symfony/Component/Form/README.md @@ -1,26 +1,13 @@ Form Component ============== -Form provides tools for defining forms, rendering and mapping request data to -related models. Furthermore it provides integration with the Validation -component. +The Form component allows you to easily create, process and reuse HTML forms. Resources --------- -Silex integration: - -https://github.com/silexphp/Silex/blob/master/src/Silex/Provider/FormServiceProvider.php - -Documentation: - -https://symfony.com/doc/2.7/book/forms.html - -Resources ---------- - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Form/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/form/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/HttpFoundation/README.md b/src/Symfony/Component/HttpFoundation/README.md index 11ad6eef54..8907f0b967 100644 --- a/src/Symfony/Component/HttpFoundation/README.md +++ b/src/Symfony/Component/HttpFoundation/README.md @@ -1,56 +1,14 @@ HttpFoundation Component ======================== -HttpFoundation defines an object-oriented layer for the HTTP specification. - -It provides an abstraction for requests, responses, uploaded files, cookies, -sessions, ... - -In this example, we get a Request object from the current PHP global -variables: - -```php -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -$request = Request::createFromGlobals(); -echo $request->getPathInfo(); -``` - -You can also create a Request directly -- that's interesting for unit testing: - -```php -$request = Request::create('/?foo=bar', 'GET'); -echo $request->getPathInfo(); -``` - -And here is how to create and send a Response: - -```php -$response = new Response('Not Found', 404, array('Content-Type' => 'text/plain')); -$response->send(); -``` - -The Request and the Response classes have many other methods that implement -the HTTP specification. - -Loading -------- - -If you are not using Composer but are using PHP 5.3.x, you must add the following to your autoloader: - -```php -// SessionHandlerInterface -if (!interface_exists('SessionHandlerInterface')) { - $loader->registerPrefixFallback(__DIR__.'/../vendor/symfony/src/Symfony/Component/HttpFoundation/Resources/stubs'); -} -``` +The HttpFoundation component defines an object-oriented layer for the HTTP +specification. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/HttpFoundation/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/http_foundation/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php b/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php index 302faa17d0..2ab6c8589e 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php @@ -57,7 +57,14 @@ class FragmentListener implements EventSubscriberInterface { $request = $event->getRequest(); - if ($request->attributes->has('_controller') || $this->fragmentPath !== rawurldecode($request->getPathInfo())) { + if ($this->fragmentPath !== rawurldecode($request->getPathInfo())) { + return; + } + + if ($request->attributes->has('_controller')) { + // Is a sub-request: no need to parse _path but it should still be removed from query parameters as below. + $request->query->remove('_path'); + return; } diff --git a/src/Symfony/Component/HttpKernel/README.md b/src/Symfony/Component/HttpKernel/README.md index 9ec8c0427b..cc5e74b6bc 100644 --- a/src/Symfony/Component/HttpKernel/README.md +++ b/src/Symfony/Component/HttpKernel/README.md @@ -1,99 +1,16 @@ HttpKernel Component ==================== -HttpKernel provides the building blocks to create flexible and fast HTTP-based -frameworks. - -``HttpKernelInterface`` is the core interface of the Symfony full-stack -framework: - -```php -interface HttpKernelInterface -{ - /** - * Handles a Request to convert it to a Response. - * - * @param Request $request A Request instance - * - * @return Response A Response instance - */ - function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true); -} -``` - -It takes a ``Request`` as an input and should return a ``Response`` as an -output. Using this interface makes your code compatible with all frameworks -using the Symfony components. And this will give you many cool features for -free. - -Creating a framework based on the Symfony components is really easy. Here is -a very simple, but fully-featured framework based on the Symfony components: - -```php -$routes = new RouteCollection(); -$routes->add('hello', new Route('/hello', array('_controller' => - function (Request $request) { - return new Response(sprintf("Hello %s", $request->get('name'))); - } -))); - -$request = Request::createFromGlobals(); - -$context = new RequestContext(); -$context->fromRequest($request); - -$matcher = new UrlMatcher($routes, $context); - -$dispatcher = new EventDispatcher(); -$dispatcher->addSubscriber(new RouterListener($matcher)); - -$resolver = new ControllerResolver(); - -$kernel = new HttpKernel($dispatcher, $resolver); - -$kernel->handle($request)->send(); -``` - -This is all you need to create a flexible framework with the Symfony -components. - -Want to add an HTTP reverse proxy and benefit from HTTP caching and Edge Side -Includes? - -```php -$kernel = new HttpKernel($dispatcher, $resolver); - -$kernel = new HttpCache($kernel, new Store(__DIR__.'/cache')); -``` - -Want to functional test this small framework? - -```php -$client = new Client($kernel); -$crawler = $client->request('GET', '/hello/Fabien'); - -$this->assertEquals('Fabien', $crawler->filter('p > span')->text()); -``` - -Want nice error pages instead of ugly PHP exceptions? - -```php -$dispatcher->addSubscriber(new ExceptionListener(function (Request $request) { - $msg = 'Something went wrong! ('.$request->get('exception')->getMessage().')'; - - return new Response($msg, 500); -})); -``` - -And that's why the simple looking ``HttpKernelInterface`` is so powerful. It -gives you access to a lot of cool features, ready to be used out of the box, -with no efforts. +The HttpKernel component provides a structured process for converting a Request +into a Response by making use of the EventDispatcher component. It's flexible +enough to create a full-stack framework (Symfony), a micro-framework (Silex) or +an advanced CMS system (Drupal). Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/HttpKernel/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/http_kernel/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php index fd5d63b167..7cfce98f2e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php @@ -89,6 +89,31 @@ class FragmentListenerTest extends \PHPUnit_Framework_TestCase $this->assertFalse($request->query->has('_path')); } + public function testRemovesPathWithControllerDefined() + { + $request = Request::create('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo'); + + $listener = new FragmentListener(new UriSigner('foo')); + $event = $this->createGetResponseEvent($request, HttpKernelInterface::SUB_REQUEST); + + $listener->onKernelRequest($event); + + $this->assertFalse($request->query->has('_path')); + } + + public function testRemovesPathWithControllerNotDefined() + { + $signer = new UriSigner('foo'); + $request = Request::create($signer->sign('http://example.com/_fragment?_path=foo%3Dbar'), 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1')); + + $listener = new FragmentListener($signer); + $event = $this->createGetResponseEvent($request); + + $listener->onKernelRequest($event); + + $this->assertFalse($request->query->has('_path')); + } + private function createGetResponseEvent(Request $request, $requestType = HttpKernelInterface::MASTER_REQUEST) { return new GetResponseEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, $requestType); diff --git a/src/Symfony/Component/Intl/README.md b/src/Symfony/Component/Intl/README.md index 11bc73130c..30cb5093c4 100644 --- a/src/Symfony/Component/Intl/README.md +++ b/src/Symfony/Component/Intl/README.md @@ -1,25 +1,19 @@ Intl Component ============= -A PHP replacement layer for the C intl extension that includes additional data -from the ICU library. +A PHP replacement layer for the C intl extension that also provides access to +the localization data of the ICU library. The replacement layer is limited to the locale "en". If you want to use other -locales, you should [install the intl extension] [0] instead. - -Documentation -------------- - -The documentation for the component can be found [online] [1]. +locales, you should [install the intl PHP extension] [0] instead. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Intl/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/intl.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) [0]: http://www.php.net/manual/en/intl.setup.php -[1]: https://symfony.com/doc/2.7/components/intl.html diff --git a/src/Symfony/Component/Locale/README.md b/src/Symfony/Component/Locale/README.md index d2298ec532..cea6d8af58 100644 --- a/src/Symfony/Component/Locale/README.md +++ b/src/Symfony/Component/Locale/README.md @@ -4,5 +4,5 @@ Locale Component Locale provides fallback code to handle cases when the ``intl`` extension is missing. -The Locale component is deprecated since version 2.3 and will be removed in +The Locale component is deprecated since version 2.3 and was removed in Symfony 3.0. You should use the more capable Intl component instead. diff --git a/src/Symfony/Component/OptionsResolver/README.md b/src/Symfony/Component/OptionsResolver/README.md index cd7a7405db..5768f68e7f 100644 --- a/src/Symfony/Component/OptionsResolver/README.md +++ b/src/Symfony/Component/OptionsResolver/README.md @@ -1,20 +1,15 @@ OptionsResolver Component ========================= -This component processes and validates option arrays. - -Documentation -------------- - -The documentation for the component can be found [online] [1]. +The OptionsResolver component is `array_replace on steroids. It allows you to +create an options system with required options, defaults, validation (type, +value), normalization and more. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/OptionsResolver/ - $ composer install - $ phpunit - -[1]: https://symfony.com/doc/current/components/options_resolver.html + * [Documentation](https://symfony.com/doc/current/components/options_resolver.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Process/README.md b/src/Symfony/Component/Process/README.md index 7222fe8957..b7ca5b4254 100644 --- a/src/Symfony/Component/Process/README.md +++ b/src/Symfony/Component/Process/README.md @@ -1,65 +1,13 @@ Process Component ================= -Process executes commands in sub-processes. - -In this example, we run a simple directory listing and get the result back: - -```php -use Symfony\Component\Process\Process; -use Symfony\Component\Process\Exception\ProcessFailedException; - -$process = new Process('ls -lsa'); -$process->setTimeout(3600); -$process->run(); -if (!$process->isSuccessful()) { - throw new ProcessFailedException($process); -} - -print $process->getOutput(); -``` - -You can think that this is easy to achieve with plain PHP but it's not especially -if you want to take care of the subtle differences between the different platforms. - -You can simplify the code by using `mustRun()` instead of `run()`, which will -throw a `ProcessFailedException` automatically in case of a problem: - -```php -use Symfony\Component\Process\Process; - -$process = new Process('ls -lsa'); -$process->setTimeout(3600); -$process->mustRun(); - -print $process->getOutput(); -``` - -And if you want to be able to get some feedback in real-time, just pass an -anonymous function to the ``run()`` method and you will get the output buffer -as it becomes available: - -```php -use Symfony\Component\Process\Process; - -$process = new Process('ls -lsa'); -$process->run(function ($type, $buffer) { - if (Process::ERR === $type) { - echo 'ERR > '.$buffer; - } else { - echo 'OUT > '.$buffer; - } -}); -``` - -That's great if you want to execute a long running command (like rsync-ing files to a -remote server) and give feedback to the user in real-time. +The Process component executes commands in sub-processes. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Process/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/process.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/PropertyAccess/README.md b/src/Symfony/Component/PropertyAccess/README.md index 9fb92f058d..1959fd9e93 100644 --- a/src/Symfony/Component/PropertyAccess/README.md +++ b/src/Symfony/Component/PropertyAccess/README.md @@ -1,14 +1,14 @@ PropertyAccess Component ======================== -PropertyAccess reads/writes values from/to object/array graphs using a simple -string notation. +The PropertyAccess component provides function to read and write from/to an +object or array using a simple string notation. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/PropertyAccess/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/property_access/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Routing/README.md b/src/Symfony/Component/Routing/README.md index 1a94583a87..88fb1fde5a 100644 --- a/src/Symfony/Component/Routing/README.md +++ b/src/Symfony/Component/Routing/README.md @@ -1,36 +1,13 @@ Routing Component ================= -Routing associates a request with the code that will convert it to a response. - -The example below demonstrates how you can set up a fully working routing -system: - -```php -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Matcher\UrlMatcher; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; - -$routes = new RouteCollection(); -$routes->add('hello', new Route('/hello', array('controller' => 'foo'))); - -$context = new RequestContext(); - -// this is optional and can be done without a Request instance -$context->fromRequest(Request::createFromGlobals()); - -$matcher = new UrlMatcher($routes, $context); - -$parameters = $matcher->match('/hello'); -``` +The Routing component maps an HTTP request to a set of configuration variables. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Routing/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/routing/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Security/README.md b/src/Symfony/Component/Security/README.md index c41b673f79..b8bba12f20 100644 --- a/src/Symfony/Component/Security/README.md +++ b/src/Symfony/Component/Security/README.md @@ -1,23 +1,18 @@ Security Component ================== -Security provides an infrastructure for sophisticated authorization systems, -which makes it possible to easily separate the actual authorization logic from -so called user providers that hold the users credentials. It is inspired by -the Java Spring framework. +The Security component provides a complete security system for your web +application. It ships with facilities for authenticating using HTTP basic or +digest authentication, interactive form login or X.509 certificate login, but +also allows you to implement your own authentication strategies. Furthermore, +the component provides ways to authorize authenticated users based on their +roles, and it contains an advanced ACL system. Resources --------- -Documentation: - -https://symfony.com/doc/2.7/book/security.html - -Tests ------ - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Security/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/security/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php index ce0c4758f1..d1f09f6eaf 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -366,7 +366,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec { $append = true; - if (is_array($data) || $data instanceof \Traversable) { + if (is_array($data) || ($data instanceof \Traversable && !$this->serializer->supportsNormalization($data, $this->format))) { foreach ($data as $key => $data) { //Ah this is the magic @ attribute types. if (0 === strpos($key, '@') && is_scalar($data) && $this->isElementNameValid($attributeName = substr($key, 1))) { diff --git a/src/Symfony/Component/Serializer/README.md b/src/Symfony/Component/Serializer/README.md index 156a288426..14270b5363 100644 --- a/src/Symfony/Component/Serializer/README.md +++ b/src/Symfony/Component/Serializer/README.md @@ -1,15 +1,16 @@ Serializer Component ==================== -With the Serializer component it's possible to handle serializing data structures, -including object graphs, into array structures or other formats like XML and JSON. -It can also handle deserializing XML and JSON back to object graphs. +With the Serializer component it's possible to handle serializing data +structures, including object graphs, into array structures or other formats like +XML and JSON. It can also handle deserializing XML and JSON back to object +graphs. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Serializer/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/serializer.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php index 72e2e6a23b..717004af05 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Serializer\Tests\Encoder; use Symfony\Component\Serializer\Tests\Fixtures\Dummy; +use Symfony\Component\Serializer\Tests\Fixtures\NormalizableTraversableDummy; use Symfony\Component\Serializer\Tests\Fixtures\ScalarDummy; use Symfony\Component\Serializer\Encoder\XmlEncoder; use Symfony\Component\Serializer\Serializer; @@ -248,6 +249,21 @@ XML; $this->assertEquals($expected, $serializer->serialize($array, 'xml', $options)); } + public function testEncodeTraversableWhenNormalizable() { + $this->encoder = new XmlEncoder(); + $serializer = new Serializer(array(new CustomNormalizer()), array('xml' => new XmlEncoder())); + $this->encoder->setSerializer($serializer); + + $expected = << +normalizedFoonormalizedBar + +XML; + + $this->assertEquals($expected, $serializer->serialize(new NormalizableTraversableDummy(), 'xml')); + + } + public function testDecode() { $source = $this->getXmlSource(); diff --git a/src/Symfony/Component/Stopwatch/README.md b/src/Symfony/Component/Stopwatch/README.md index 611df90ca5..eb0ebb3fa8 100644 --- a/src/Symfony/Component/Stopwatch/README.md +++ b/src/Symfony/Component/Stopwatch/README.md @@ -1,13 +1,13 @@ Stopwatch Component =================== -Stopwatch provides a way to profile code. +The Stopwatch component provides a way to profile code. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Stopwatch/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/stopwatch.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Templating/README.md b/src/Symfony/Component/Templating/README.md index 253eb4f507..58e2a0a5c6 100644 --- a/src/Symfony/Component/Templating/README.md +++ b/src/Symfony/Component/Templating/README.md @@ -1,18 +1,19 @@ Templating Component ==================== -Templating provides all the tools needed to build any kind of template system. +The Templating component provides all the tools needed to build any kind of +template system. -It provides an infrastructure to load template files and optionally monitor -them for changes. It also provides a concrete template engine implementation -using PHP with additional tools for escaping and separating templates into -blocks and layouts. +It provides an infrastructure to load template files and optionally monitor them +for changes. It also provides a concrete template engine implementation using +PHP with additional tools for escaping and separating templates into blocks and +layouts. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Templating/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/templating/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Translation/README.md b/src/Symfony/Component/Translation/README.md index 2b46b51771..46f3d1f2f2 100644 --- a/src/Symfony/Component/Translation/README.md +++ b/src/Symfony/Component/Translation/README.md @@ -1,37 +1,13 @@ Translation Component ===================== -Translation provides tools for loading translation files and generating -translated strings from these including support for pluralization. - -```php -use Symfony\Component\Translation\Translator; -use Symfony\Component\Translation\MessageSelector; -use Symfony\Component\Translation\Loader\ArrayLoader; - -$translator = new Translator('fr_FR', new MessageSelector()); -$translator->setFallbackLocales(array('fr')); -$translator->addLoader('array', new ArrayLoader()); -$translator->addResource('array', array( - 'Hello World!' => 'Bonjour', -), 'fr'); - -echo $translator->trans('Hello World!')."\n"; -``` +The Translation component provides tools to internationalize your application. Resources --------- -Silex integration: - -https://github.com/silexphp/Silex/blob/master/src/Silex/Provider/TranslationServiceProvider.php - -Documentation: - -https://symfony.com/doc/2.7/book/translation.html - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Translation/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/translation/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Validator/README.md b/src/Symfony/Component/Validator/README.md index 7a62399f75..9dfbffb3f5 100644 --- a/src/Symfony/Component/Validator/README.md +++ b/src/Symfony/Component/Validator/README.md @@ -1,126 +1,16 @@ Validator Component =================== -This component is based on the JSR-303 Bean Validation specification and -enables specifying validation rules for classes using XML, YAML, PHP or -annotations, which can then be checked against instances of these classes. - -Usage ------ - -The component provides "validation constraints", which are simple objects -containing the rules for the validation. Let's validate a simple string -as an example: - -```php -use Symfony\Component\Validator\Validation; -use Symfony\Component\Validator\Constraints\Length; - -$validator = Validation::createValidator(); - -$violations = $validator->validate('Bernhard', new Length(array('min' => 10))); -``` - -This validation will fail because the given string is shorter than ten -characters. The precise errors, here called "constraint violations", are -returned by the validator. You can analyze these or return them to the user. -If the violation list is empty, validation succeeded. - -Validation of arrays is possible using the `Collection` constraint: - -```php -use Symfony\Component\Validator\Validation; -use Symfony\Component\Validator\Constraints as Assert; - -$validator = Validation::createValidator(); - -$constraint = new Assert\Collection(array( - 'name' => new Assert\Collection(array( - 'first_name' => new Assert\Length(array('min' => 101)), - 'last_name' => new Assert\Length(array('min' => 1)), - )), - 'email' => new Assert\Email(), - 'simple' => new Assert\Length(array('min' => 102)), - 'gender' => new Assert\Choice(array(3, 4)), - 'file' => new Assert\File(), - 'password' => new Assert\Length(array('min' => 60)), -)); - -$violations = $validator->validate($input, $constraint); -``` - -Again, the validator returns the list of violations. - -Validation of objects is possible using "constraint mapping". With such -a mapping you can put constraints onto properties and objects of classes. -Whenever an object of this class is validated, its properties and -method results are matched against the constraints. - -```php -use Symfony\Component\Validator\Validation; -use Symfony\Component\Validator\Constraints as Assert; - -class User -{ - /** - * @Assert\Length(min = 3) - * @Assert\NotBlank - */ - private $name; - - /** - * @Assert\Email - * @Assert\NotBlank - */ - private $email; - - public function __construct($name, $email) - { - $this->name = $name; - $this->email = $email; - } - - /** - * @Assert\IsTrue(message = "The user should have a Google Mail account") - */ - public function isGmailUser() - { - return false !== strpos($this->email, '@gmail.com'); - } -} - -$validator = Validation::createValidatorBuilder() - ->enableAnnotationMapping() - ->getValidator(); - -$user = new User('John Doe', 'john@example.com'); - -$violations = $validator->validate($user); -``` - -This example uses the annotation support of Doctrine Common to -map constraints to properties and methods. You can also map constraints -using XML, YAML or plain PHP, if you dislike annotations or don't want -to include Doctrine. Check the documentation for more information about -these drivers. +The Validator component provides tools to validate values following the +[JSR-303 Bean Validation specification][1]. Resources --------- -Silex integration: + * [Documentation](https://symfony.com/doc/current/book/validation.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) -https://github.com/silexphp/Silex/blob/master/src/Silex/Provider/ValidatorServiceProvider.php - -Documentation: - -https://symfony.com/doc/2.7/book/validation.html - -JSR-303 Specification: - -http://jcp.org/en/jsr/detail?id=303 - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Validator/ - $ composer install - $ phpunit +[1]: http://jcp.org/en/jsr/detail?id=303 diff --git a/src/Symfony/Component/Yaml/README.md b/src/Symfony/Component/Yaml/README.md index 85a9786735..0d324881ce 100644 --- a/src/Symfony/Component/Yaml/README.md +++ b/src/Symfony/Component/Yaml/README.md @@ -1,21 +1,13 @@ Yaml Component ============== -YAML implements most of the YAML 1.2 specification. - -```php -use Symfony\Component\Yaml\Yaml; - -$array = Yaml::parse(file_get_contents(filename)); - -print Yaml::dump($array); -``` +The Yaml component loads and dumps YAML files. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Yaml/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/yaml/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony)