From de6fdff7f5ca1ec92b64babca483d45352c446c2 Mon Sep 17 00:00:00 2001 From: Dany Maillard Date: Wed, 28 Dec 2016 17:02:09 +0100 Subject: [PATCH 1/3] Add framework.secret doc --- .../Command/ConfigDumpReferenceCommand.php | 10 ++++-- .../DependencyInjection/Configuration.php | 4 ++- .../Component/Config/Definition/BaseNode.php | 20 ++++++++++++ .../Definition/Builder/NodeDefinition.php | 22 +++++++++++++ .../Definition/Dumper/ReferenceDumper.php | 32 +++++++++++++++++++ .../Definition/Dumper/XmlReferenceDumper.php | 9 ++++-- .../Definition/Dumper/YamlReferenceDumper.php | 11 ++++--- .../Config/Definition/NodeInterface.php | 7 ++++ 8 files changed, 104 insertions(+), 11 deletions(-) create mode 100644 src/Symfony/Component/Config/Definition/Dumper/ReferenceDumper.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php index 476813fc3621e..10a42f89b2f1d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php @@ -37,7 +37,6 @@ protected function configure() ->setName('config:dump-reference') ->setDefinition(array( new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle name or the extension alias'), - new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (yaml or xml)', 'yaml'), )) ->setDescription('Dumps the default configuration for an extension') @@ -60,6 +59,10 @@ protected function configure() php %command.full_name% framework profiler.matcher +The --with-doc option dumps nodes with documentation URL. + + php %command.full_name% FrameworkBundle --with-doc + EOF ) ; @@ -110,14 +113,15 @@ protected function execute(InputInterface $input, OutputInterface $output) $message .= sprintf(' at path "%s"', $path); } + $withDoc = $input->getOption('with-doc'); switch ($format) { case 'yaml': $io->writeln(sprintf('# %s', $message)); - $dumper = new YamlReferenceDumper(); + $dumper = new YamlReferenceDumper($withDoc); break; case 'xml': $io->writeln(sprintf('', $message)); - $dumper = new XmlReferenceDumper(); + $dumper = new XmlReferenceDumper($withDoc); break; default: $io->writeln($message); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index b937582d60c4f..3d1580b10401d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -59,7 +59,9 @@ public function getConfigTreeBuilder() }) ->end() ->children() - ->scalarNode('secret')->end() + ->scalarNode('secret') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#secret') + ->end() ->scalarNode('http_method_override') ->info("Set true to enable support for the '_method' request parameter to determine the intended HTTP method on POST requests. Note: When using the HttpCache, you need to call the method in your front controller instead") ->defaultTrue() diff --git a/src/Symfony/Component/Config/Definition/BaseNode.php b/src/Symfony/Component/Config/Definition/BaseNode.php index dbf36335b69e3..55ae9569b6a84 100644 --- a/src/Symfony/Component/Config/Definition/BaseNode.php +++ b/src/Symfony/Component/Config/Definition/BaseNode.php @@ -207,6 +207,26 @@ public function getPath() return $path; } + /** + * Sets an documentation URL. + * + * @param string $doc The documentation URL + */ + public function setDoc($doc) + { + $this->setAttribute('doc', $doc); + } + + /** + * Retrieves the documentation URL configuration for this node. + * + * @return string The documentation URL + */ + public function getDoc() + { + return $this->getAttribute('doc'); + } + /** * Merges two values together. * diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php index 1b712a3150bc3..a034b44bc73ec 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php @@ -13,6 +13,7 @@ use Symfony\Component\Config\Definition\NodeInterface; use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException; +use Symfony\Component\HttpKernel\Kernel; /** * This class provides a fluent interface for defining a node. @@ -340,4 +341,25 @@ protected function normalization() * @throws InvalidDefinitionException When the definition is invalid */ abstract protected function createNode(); + + /** + * Sets doc configuration. + * + * @param string $doc + * + * @return NodeDefinition|$this + */ + public function doc($doc) + { + if (false === filter_var($doc, FILTER_VALIDATE_URL)) { + throw new \InvalidArgumentException(sprintf('The "%s" is not a valid documentation URL.', $doc)); + } + + // Adds sf version + if (false !== strpos($doc, 'https://symfony.com/doc/')) { + $doc = sprintf($doc, Kernel::MAJOR_VERSION.'.'.Kernel::MINOR_VERSION); + } + + return $this->attribute('doc', $doc); + } } diff --git a/src/Symfony/Component/Config/Definition/Dumper/ReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/ReferenceDumper.php new file mode 100644 index 0000000000000..329e6bead98e4 --- /dev/null +++ b/src/Symfony/Component/Config/Definition/Dumper/ReferenceDumper.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Definition\Dumper; + +use Symfony\Component\Config\Definition\ConfigurationInterface; + +/** + * Dumps a reference configuration for the given configuration/node instance. + * + * @author Dany Maillard + */ +abstract class ReferenceDumper +{ + protected $reference; + protected $withDoc; + + function __construct($withDoc = false) + { + $this->withDoc = $withDoc; + } + + abstract public function dump(ConfigurationInterface $configuration, $namespace = null); +} diff --git a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php index ec5460f2f53c7..1aa4e6260e1ea 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php @@ -22,10 +22,8 @@ * * @author Wouter J */ -class XmlReferenceDumper +class XmlReferenceDumper extends ReferenceDumper { - private $reference; - public function dump(ConfigurationInterface $configuration, $namespace = null) { return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree(), $namespace); @@ -149,6 +147,11 @@ private function writeNode(NodeInterface $node, $depth = 0, $root = false, $name $comments[] = 'Example: '.$example; } + // doc + if ($this->withDoc && $doc = $child->getDoc()) { + $comments[] = 'Doc: '.$doc; + } + if ($child->isRequired()) { $comments[] = 'Required'; } diff --git a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php index 16076354db515..1dc01503a734a 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php @@ -24,11 +24,9 @@ * * @author Kevin Bond */ -class YamlReferenceDumper +class YamlReferenceDumper extends ReferenceDumper { - private $reference; - - public function dump(ConfigurationInterface $configuration) + public function dump(ConfigurationInterface $configuration, $namespace = null) { return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree()); } @@ -128,6 +126,11 @@ private function writeNode(NodeInterface $node, $depth = 0, $prototypedArray = f $comments[] = 'Example: '.$example; } + // doc + if ($this->withDoc && $doc = $node->getDoc()) { + $comments[] = 'Doc: '.$doc; + } + $default = (string) $default != '' ? ' '.$default : ''; $comments = count($comments) ? '# '.implode(', ', $comments) : ''; diff --git a/src/Symfony/Component/Config/Definition/NodeInterface.php b/src/Symfony/Component/Config/Definition/NodeInterface.php index b9bddc49385a3..fcecc0e398d63 100644 --- a/src/Symfony/Component/Config/Definition/NodeInterface.php +++ b/src/Symfony/Component/Config/Definition/NodeInterface.php @@ -58,6 +58,13 @@ public function hasDefaultValue(); */ public function getDefaultValue(); + /** + * Returns the documentation URL of the node. + * + * @return string The documentation URL + */ + public function getDoc(); + /** * Normalizes the supplied value. * From 6e3ad288fa9e1d19ac2dcc967ea85007520e3c34 Mon Sep 17 00:00:00 2001 From: Dany Maillard Date: Wed, 22 Feb 2017 23:16:22 +0100 Subject: [PATCH 2/3] Update docs of framework config --- .../Command/ConfigDumpReferenceCommand.php | 2 + .../DependencyInjection/Configuration.php | 250 ++++++++++++++---- 2 files changed, 204 insertions(+), 48 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php index 10a42f89b2f1d..aadb08ac2159d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php @@ -37,7 +37,9 @@ protected function configure() ->setName('config:dump-reference') ->setDefinition(array( new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle name or the extension alias'), + new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (yaml or xml)', 'yaml'), + new InputOption('with-doc', null, InputOption::VALUE_NONE, 'Show documentation link'), )) ->setDescription('Dumps the default configuration for an extension') ->setHelp(<<<'EOF' diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 3d1580b10401d..80e30265bf3ce 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -65,6 +65,7 @@ public function getConfigTreeBuilder() ->scalarNode('http_method_override') ->info("Set true to enable support for the '_method' request parameter to determine the intended HTTP method on POST requests. Note: When using the HttpCache, you need to call the method in your front controller instead") ->defaultTrue() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#http_method_override') ->end() ->arrayNode('trusted_proxies') ->beforeNormalization() @@ -95,13 +96,23 @@ public function getConfigTreeBuilder() ->thenInvalid('Invalid proxy IP "%s"') ->end() ->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#trusted_proxies') + ->end() + ->scalarNode('ide') + ->defaultNull() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#ide') + ->end() + ->booleanNode('test') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#test') + ->end() + ->scalarNode('default_locale') + ->defaultValue('en') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#default_locale') ->end() - ->scalarNode('ide')->defaultNull()->end() - ->booleanNode('test')->end() - ->scalarNode('default_locale')->defaultValue('en')->end() ->arrayNode('trusted_hosts') ->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end() ->prototype('scalar')->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#trusted_hosts') ->end() ->end() ; @@ -136,6 +147,7 @@ private function addCsrfSection(ArrayNodeDefinition $rootNode) ->children() ->arrayNode('csrf_protection') ->canBeEnabled() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#csrf_protection') ->end() ->end() ; @@ -155,9 +167,13 @@ private function addFormSection(ArrayNodeDefinition $rootNode) ->treatNullLike(array('enabled' => true)) ->addDefaultsIfNotSet() ->children() - ->booleanNode('enabled')->defaultNull()->end() // defaults to framework.csrf_protection.enabled + ->booleanNode('enabled') + ->defaultNull() // defaults to framework.csrf_protection.enabled + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#reference-csrf-protection-enabled') + ->end() ->scalarNode('field_name')->defaultValue('_token')->end() ->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#csrf_protection') ->end() ->end() ->end() @@ -172,6 +188,7 @@ private function addEsiSection(ArrayNodeDefinition $rootNode) ->arrayNode('esi') ->info('esi configuration') ->canBeEnabled() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#esi') ->end() ->end() ; @@ -184,6 +201,7 @@ private function addSsiSection(ArrayNodeDefinition $rootNode) ->arrayNode('ssi') ->info('ssi configuration') ->canBeEnabled() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#ssi') ->end() ->end(); } @@ -196,8 +214,12 @@ private function addFragmentsSection(ArrayNodeDefinition $rootNode) ->info('fragments configuration') ->canBeEnabled() ->children() - ->scalarNode('path')->defaultValue('/_fragment')->end() + ->scalarNode('path') + ->defaultValue('/_fragment') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#path') + ->end() ->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#fragments') ->end() ->end() ; @@ -211,10 +233,22 @@ private function addProfilerSection(ArrayNodeDefinition $rootNode) ->info('profiler configuration') ->canBeEnabled() ->children() - ->booleanNode('collect')->defaultTrue()->end() - ->booleanNode('only_exceptions')->defaultFalse()->end() - ->booleanNode('only_master_requests')->defaultFalse()->end() - ->scalarNode('dsn')->defaultValue('file:%kernel.cache_dir%/profiler')->end() + ->booleanNode('collect') + ->defaultTrue() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#collect') + ->end() + ->booleanNode('only_exceptions') + ->defaultFalse() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#only-exceptions') + ->end() + ->booleanNode('only_master_requests') + ->defaultFalse() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#only-master-requests') + ->end() + ->scalarNode('dsn') + ->defaultValue('file:%kernel.cache_dir%/profiler') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#dsn') + ->end() ->arrayNode('matcher') ->canBeEnabled() ->performNoDeepMerging() @@ -223,13 +257,17 @@ private function addProfilerSection(ArrayNodeDefinition $rootNode) ->scalarNode('path') ->info('use the urldecoded format') ->example('^/path to resource/') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#reference-profiler-matcher-path') + ->end() + ->scalarNode('service') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#service') ->end() - ->scalarNode('service')->end() ->arrayNode('ips') ->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end() ->prototype('scalar')->end() ->end() ->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#matcher') ->end() ->end() ->end() @@ -385,10 +423,21 @@ private function addRouterSection(ArrayNodeDefinition $rootNode) ->info('router configuration') ->canBeEnabled() ->children() - ->scalarNode('resource')->isRequired()->end() - ->scalarNode('type')->end() - ->scalarNode('http_port')->defaultValue(80)->end() - ->scalarNode('https_port')->defaultValue(443)->end() + ->scalarNode('resource') + ->isRequired() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#resource') + ->end() + ->scalarNode('type') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#type') + ->end() + ->scalarNode('http_port') + ->defaultValue(80) + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#http-port') + ->end() + ->scalarNode('https_port') + ->defaultValue(443) + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#https-port') + ->end() ->scalarNode('strict_requirements') ->info( "set to true to throw an exception when a parameter does not match the requirements\n". @@ -397,6 +446,7 @@ private function addRouterSection(ArrayNodeDefinition $rootNode) "'true' is the preferred configuration in development mode, while 'false' or 'null' might be preferred in production" ) ->defaultTrue() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#strict-requirements') ->end() ->end() ->end() @@ -412,19 +462,48 @@ private function addSessionSection(ArrayNodeDefinition $rootNode) ->info('session configuration') ->canBeEnabled() ->children() - ->scalarNode('storage_id')->defaultValue('session.storage.native')->end() - ->scalarNode('handler_id')->defaultValue('session.handler.native_file')->end() - ->scalarNode('name')->end() - ->scalarNode('cookie_lifetime')->end() - ->scalarNode('cookie_path')->end() - ->scalarNode('cookie_domain')->end() - ->booleanNode('cookie_secure')->end() - ->booleanNode('cookie_httponly')->defaultTrue()->end() + ->scalarNode('storage_id') + ->defaultValue('session.storage.native') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#storage-id') + ->end() + ->scalarNode('handler_id') + ->defaultValue('session.handler.native_file') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#handler-id') + ->end() + ->scalarNode('name') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#name') + ->end() + ->scalarNode('cookie_lifetime') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#cookie-lifetime') + ->end() + ->scalarNode('cookie_path') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#cookie-path') + ->end() + ->scalarNode('cookie_domain') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#cookie-domain') + ->end() + ->booleanNode('cookie_secure') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#cookie-secure') + ->end() + ->booleanNode('cookie_httponly') + ->defaultTrue() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#cookie-httponly') + ->end() ->booleanNode('use_cookies')->end() - ->scalarNode('gc_divisor')->end() - ->scalarNode('gc_probability')->defaultValue(1)->end() - ->scalarNode('gc_maxlifetime')->end() - ->scalarNode('save_path')->defaultValue('%kernel.cache_dir%/sessions')->end() + ->scalarNode('gc_divisor') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#gc-divisor') + ->end() + ->scalarNode('gc_probability') + ->defaultValue(1) + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#gc-probability') + ->end() + ->scalarNode('gc_maxlifetime') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#gc-maxlifetime') + ->end() + ->scalarNode('save_path') + ->defaultValue('%kernel.cache_dir%/sessions') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#save-path') + ->end() ->integerNode('metadata_update_threshold') ->defaultValue('0') ->info('seconds to wait between 2 session metadata updates, it will also prevent the session handler to write if the session has not changed') @@ -476,8 +555,13 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode) ->then(function () { return array('enabled' => false, 'engines' => false); }) ->end() ->children() - ->scalarNode('hinclude_default_template')->defaultNull()->end() - ->scalarNode('cache')->end() + ->scalarNode('hinclude_default_template') + ->defaultNull() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#hinclude-default-template') + ->end() + ->scalarNode('cache') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#cache') + ->end() ->arrayNode('form') ->addDefaultsIfNotSet() ->fixXmlConfig('resource') @@ -491,8 +575,10 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode) return array_merge(array('FrameworkBundle:Form'), $v); }) ->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#resources') ->end() ->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#reference-templating-form') ->end() ->end() ->fixXmlConfig('engine') @@ -507,6 +593,7 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode) ->then(function ($v) { return array($v); }) ->end() ->prototype('scalar')->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#engines') ->end() ->end() ->fixXmlConfig('loader') @@ -517,6 +604,7 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode) ->then(function ($v) { return array($v); }) ->end() ->prototype('scalar')->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#loaders') ->end() ->end() ->end() @@ -533,10 +621,22 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode) ->{!class_exists(FullStack::class) && class_exists(Package::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->fixXmlConfig('base_url') ->children() - ->scalarNode('version_strategy')->defaultNull()->end() - ->scalarNode('version')->defaultNull()->end() - ->scalarNode('version_format')->defaultValue('%%s?%%s')->end() - ->scalarNode('base_path')->defaultValue('')->end() + ->scalarNode('version_strategy') + ->defaultNull() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#version-strategy') + ->end() + ->scalarNode('version') + ->defaultNull() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#version') + ->end() + ->scalarNode('version_format') + ->defaultValue('%%s?%%s') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#version-format') + ->end() + ->scalarNode('base_path') + ->defaultValue('') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#base-path') + ->end() ->arrayNode('base_urls') ->requiresAtLeastOneElement() ->beforeNormalization() @@ -544,6 +644,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode) ->then(function ($v) { return array($v); }) ->end() ->prototype('scalar')->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#base-urls') ->end() ->end() ->validate() @@ -559,15 +660,25 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode) ->prototype('array') ->fixXmlConfig('base_url') ->children() - ->scalarNode('version_strategy')->defaultNull()->end() + ->scalarNode('version_strategy') + ->defaultNull() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#reference-assets-version-strategy') + ->end() ->scalarNode('version') ->beforeNormalization() ->ifTrue(function ($v) { return '' === $v; }) ->then(function ($v) { return; }) ->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#reference-framework-assets-version') + ->end() + ->scalarNode('version_format') + ->defaultNull() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#reference-assets-version-format') + ->end() + ->scalarNode('base_path') + ->defaultValue('') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#reference-assets-base-path') ->end() - ->scalarNode('version_format')->defaultNull()->end() - ->scalarNode('base_path')->defaultValue('')->end() ->arrayNode('base_urls') ->requiresAtLeastOneElement() ->beforeNormalization() @@ -575,6 +686,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode) ->then(function ($v) { return array($v); }) ->end() ->prototype('scalar')->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#reference-assets-base-urls') ->end() ->end() ->validate() @@ -584,6 +696,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode) ->thenInvalid('You cannot use both "version_strategy" and "version" at the same time under "assets" packages.') ->end() ->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#packages') ->end() ->end() ->end() @@ -605,10 +718,15 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode) ->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end() ->prototype('scalar')->end() ->defaultValue(array('en')) + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#fallbacks') + ->end() + ->booleanNode('logging') + ->defaultValue($this->debug) + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#logging') ->end() - ->booleanNode('logging')->defaultValue($this->debug)->end() ->arrayNode('paths') ->prototype('scalar')->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#paths') ->end() ->end() ->end() @@ -624,8 +742,13 @@ private function addValidationSection(ArrayNodeDefinition $rootNode) ->info('validation configuration') ->{!class_exists(FullStack::class) && class_exists(Validation::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->children() - ->scalarNode('cache')->end() - ->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' : 'defaultFalse'}()->end() + ->scalarNode('cache') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#reference-validation-cache') + ->end() + ->booleanNode('enable_annotations') + ->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' : 'defaultFalse'}() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#enable-annotations') + ->end() ->arrayNode('static_method') ->defaultValue(array('loadValidatorMetadata')) ->prototype('scalar')->end() @@ -635,8 +758,14 @@ private function addValidationSection(ArrayNodeDefinition $rootNode) ->then(function ($v) { return (array) $v; }) ->end() ->end() - ->scalarNode('translation_domain')->defaultValue('validators')->end() - ->booleanNode('strict_email')->defaultFalse()->end() + ->scalarNode('translation_domain') + ->defaultValue('validators') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#translation-domain') + ->end() + ->booleanNode('strict_email') + ->defaultFalse() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#strict-email') + ->end() ->arrayNode('mapping') ->addDefaultsIfNotSet() ->fixXmlConfig('path') @@ -645,6 +774,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode) ->prototype('scalar')->end() ->end() ->end() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#mapping') ->end() ->end() ->end() @@ -660,9 +790,18 @@ private function addAnnotationsSection(ArrayNodeDefinition $rootNode) ->info('annotation configuration') ->{class_exists(Annotation::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->children() - ->scalarNode('cache')->defaultValue('php_array')->end() - ->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end() - ->booleanNode('debug')->defaultValue($this->debug)->end() + ->scalarNode('cache') + ->defaultValue('php_array') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#reference-annotations-cache') + ->end() + ->scalarNode('file_cache_dir') + ->defaultValue('%kernel.cache_dir%/annotations') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#file-cache-dir') + ->end() + ->booleanNode('debug') + ->defaultValue($this->debug) + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#debug') + ->end() ->end() ->end() ->end() @@ -677,9 +816,15 @@ private function addSerializerSection(ArrayNodeDefinition $rootNode) ->info('serializer configuration') ->{!class_exists(FullStack::class) && class_exists(Serializer::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->children() - ->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' : 'defaultFalse'}()->end() - ->scalarNode('cache')->end() - ->scalarNode('name_converter')->end() + ->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' : 'defaultFalse'}() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#reference-serializer-enable-annotations') + ->end() + ->scalarNode('cache') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#reference-serializer-cache') + ->end() + ->scalarNode('name_converter') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#name-converter') + ->end() ->end() ->end() ->end() @@ -694,8 +839,14 @@ private function addPropertyAccessSection(ArrayNodeDefinition $rootNode) ->addDefaultsIfNotSet() ->info('Property access configuration') ->children() - ->booleanNode('magic_call')->defaultFalse()->end() - ->booleanNode('throw_exception_on_invalid_index')->defaultFalse()->end() + ->booleanNode('magic_call') + ->defaultFalse() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#magic-call') + ->end() + ->booleanNode('throw_exception_on_invalid_index') + ->defaultFalse() + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#throw-exception-on-invalid-index') + ->end() ->end() ->end() ->end() @@ -726,6 +877,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode) ->scalarNode('prefix_seed') ->info('Used to namespace cache keys when using several apps with the same shared backend') ->example('my-application-name') + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#prefix-seed') ->end() ->scalarNode('app') ->info('App related cache pools configuration') @@ -776,11 +928,13 @@ private function addPhpErrorsSection(ArrayNodeDefinition $rootNode) ->info('Use the app logger instead of the PHP logger for logging PHP errors.') ->defaultValue($this->debug) ->treatNullLike($this->debug) + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#log') ->end() ->booleanNode('throw') ->info('Throw PHP errors as \ErrorException instances.') ->defaultValue($this->debug) ->treatNullLike($this->debug) + ->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#throw') ->end() ->end() ->end() From d1ef8bee0e01e15b02765f79353e9b6d7ebe3650 Mon Sep 17 00:00:00 2001 From: Dany Maillard Date: Wed, 22 Feb 2017 23:55:04 +0100 Subject: [PATCH 3/3] Fix cs --- .../Component/Config/Definition/Dumper/ReferenceDumper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Config/Definition/Dumper/ReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/ReferenceDumper.php index 329e6bead98e4..9638278f85ddc 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/ReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/ReferenceDumper.php @@ -23,7 +23,7 @@ abstract class ReferenceDumper protected $reference; protected $withDoc; - function __construct($withDoc = false) + public function __construct($withDoc = false) { $this->withDoc = $withDoc; }