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
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 = <<