This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Christian Flothmann 1bfb8106d3 minor #32400 [Form] Name related PHPDoc fixes (vudaltsov)
This PR was merged into the 3.4 branch.

Discussion
----------

[Form] Name related PHPDoc fixes

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | relates to #32179
| License       | MIT
| Doc PR        | n/a

As I started working on #32179 in #32237, I noticed some PHPDoc inconsistencies around the form's name. I have researched the issue thoroughly and here's my proposal:

1. All "factory" methods (`FormFactory::create*`, `ResolvedFormType::createBuilder`, `FormBuilder::create|add`, `Form::add`) currently accept string and integer names. This should not be deprecated, because it's very convenient and natural to pass ints when adding children to types like `ChoiceType` or `CollectionType`.
1. None of the "factory" methods explicitly accepts `null` as a name, although passing `null` works the same as passing `''`. I consider passing `null` in this case to be ugly, so I corrected the builder's constructors mentioning `null` as a possible argument. One should pass an empty string `''` when creating such a form. We could also deprecate passing `null` in a PR targeting 4.4.
1. Currently the name becomes a string in the builder's (or config builder's) constructor. Which means that `FormConfigInterface::getName` always returns a string and thus the form's `$name` property is always a string. All related checks and PHPDocs should be corrected.
1. The "children accessors" (`Form::has|get|remove`, `FormBuilder::has|get|remove`) should accept both strings and ints because they are array-accessible by design (so it does not really matter, if the key is a string or an int). If it's valid to have `$collectionForm->add(1, ItemType::class)`, then it should be valid to do `$collectionForm->get(1)`. And it works in code, but is not mentioned in the PHPDoc.

ping @nicolas-grekas , @xabbuh , @HeahDude

Commits
-------

eae95c4e49 PHPDoc fixes
2019-07-13 13:29:38 +02:00
.composer Drop hirak/prestissimo 2016-05-12 07:44:15 -05:00
.github [travis] not all components have a master branch 2019-06-27 18:11:56 +02:00
src/Symfony minor #32400 [Form] Name related PHPDoc fixes (vudaltsov) 2019-07-13 13:29:38 +02:00
.appveyor.yml Skip testing the phpunit-bridge on not-master branches when $deps is empty 2019-04-12 17:12:49 +02:00
.editorconfig Update .editorconfig 2018-09-06 16:22:56 +02:00
.gitignore Add appveyor.yml for C.I. on Windows 2015-08-25 23:41:37 +02:00
.php_cs.dist fixed CS 2019-06-13 12:34:15 +02:00
.travis.yml [travis] increase concurrency 2019-06-07 19:50:04 +02:00
CHANGELOG-3.0.md Merge branch '2.8' into 3.1 2016-08-05 10:37:39 +02:00
CHANGELOG-3.1.md updated CHANGELOG for 3.1.9 2017-01-12 12:43:31 -08:00
CHANGELOG-3.2.md use behavior instead of behaviour 2019-03-25 08:48:46 +01:00
CHANGELOG-3.3.md use behavior instead of behaviour 2019-03-25 08:48:46 +01:00
CHANGELOG-3.4.md updated CHANGELOG for 3.4.29 2019-06-26 15:56:21 +02:00
CODE_OF_CONDUCT.md Added the Code of Conduct file 2018-10-10 03:13:30 -07:00
composer.json Bump phpunit-bridge 2019-06-26 12:03:25 +02:00
CONTRIBUTING.md Mention the community review guide 2016-12-18 22:02:35 +01:00
CONTRIBUTORS.md update CONTRIBUTORS for 3.4.29 2019-06-26 15:56:32 +02:00
LICENSE update year in license files 2019-01-01 14:45:19 +01:00
link Use the current working dir as default first arg in 'link' binary 2019-05-16 11:52:39 +02:00
phpunit bump phpunit-bridge cache ids 2019-07-04 19:06:26 +02:00
phpunit.xml.dist Merge branch '2.8' into 3.4 2018-11-11 20:48:54 +01:00
README.md Merge branch '2.8' into 3.4 2018-05-25 16:50:57 +02:00
UPGRADE-3.0.md use behavior instead of behaviour 2019-03-25 08:48:46 +01:00
UPGRADE-3.1.md [Serializer] Remove AbstractObjectNormalizer::isAttributeToNormalize 2016-12-08 16:02:32 +01:00
UPGRADE-3.2.md Merge branch '2.8' into 3.4 2018-02-22 13:28:57 +01:00
UPGRADE-3.3.md Merge branch '3.3' into 3.4 2017-11-30 15:59:23 +01:00
UPGRADE-3.4.md Merge branch '2.8' into 3.4 2018-05-31 12:13:22 +02:00
UPGRADE-4.0.md minor: ChoiceType callable deprecation after/before seems wrong 2019-04-26 08:22:35 +02:00

Symfony is a PHP framework for web applications and a set of reusable PHP components. Symfony is used by thousands of web applications (including BlaBlaCar.com and Spotify.com) and most of the popular PHP projects (including Drupal and Magento).

Installation

Documentation

Community

Contributing

Symfony is an Open Source, community-driven project with thousands of contributors. Join them contributing code or contributing documentation.

Security Issues

If you discover a security vulnerability within Symfony, please follow our disclosure procedure.

About Us

Symfony development is sponsored by SensioLabs, led by the Symfony Core Team and supported by Symfony contributors.