Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commited68472

Browse files
not use reflection to get value of FormType::$emptyData
1 parentcb1ee76 commited68472

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

‎src/Symfony/Component/Form/Extension/Core/Type/FormType.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@
2929
class FormTypeextends BaseType
3030
{
3131
private$dataMapper;
32-
privatestatic$emptyData =null;
32+
33+
/**
34+
* @internal
35+
*
36+
* @deprecated Don't use this property. It will be removed in symfony/form 6.0
37+
*/
38+
publicstatic$emptyData =null;
3339

3440
publicfunction__construct(PropertyAccessorInterface$propertyAccessor =null)
3541
{
@@ -159,7 +165,7 @@ public function configureOptions(OptionsResolver $resolver)
159165
};
160166

161167
// Derive "empty_data" closure from "data_class" option
162-
if (self::$emptyData ===null) {
168+
if (null ===self::$emptyData) {
163169
self::$emptyData =function (Options$options) {
164170
$class =$options['data_class'];
165171

‎src/Symfony/Component/Form/Extension/Core/Type/TextType.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
2727
// See https://github.com/symfony/symfony/issues/5906#issuecomment-203189375
2828
if ('' ===$options['empty_data']) {
2929
$builder->addViewTransformer($this);
30-
}elseif ($options['empty_data']instanceof \Closure) {
31-
$emptyData =new \ReflectionProperty(FormType::class,'emptyData');
32-
$emptyData->setAccessible(true);
33-
// Closure in "empty_data" option is the default value from FormType::configureOptions()
34-
if ($emptyData->getValue($builder->getForm()) ===$options['empty_data']) {
35-
trigger_deprecation('symfony/form','5.4','The default value of "empty_data" option in "%s" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.',__CLASS__);
36-
}
30+
}elseif (FormType::$emptyData ===$options['empty_data']) {
31+
// "empty_data" option is the default value from FormType::configureOptions()
32+
trigger_deprecation('symfony/form','5.4','The default value of "empty_data" option in "%s" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.',__CLASS__);
3733
}
3834
}
3935

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp