8000 fix #17993 - Deprecated callable strings · Simperfit/symfony@dc6588e · GitHub
[go: up one dir, main page]

Skip to content

Commit dc6588e

Browse files
author
hamza
committed
fix symfony#17993 - Deprecated callable strings
1 parent f5cf886 commit dc6588e

File tree

2 files changed

+183
-16
lines changed

2 files changed

+183
-16
lines changed

src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public function createListFromChoices($choices, $value = null)
8686
{
8787
if (is_string($value) && !is_callable($value)) {
8888
$value = new PropertyPath($value);
89+
} elseif (is_string($value) && is_callable($value)) {
90+
@trigger_error('Treating strings as callable is deprecated since version 3.1 and will throw an error in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
8991
}
9092

9193
if ($value instanceof PropertyPath) {
@@ -117,6 +119,8 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
117119
{
118120
if (is_string($value) && !is_callable($value)) {
119121
$value = new PropertyPath($value);
122+
} elseif (is_string($value) && is_callable($value)) {
123+
@trigger_error('Treating strings as callable is deprecated since version 3.1 and will throw an error in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
120124
}
121125

122126
if ($value instanceof PropertyPath) {
@@ -153,6 +157,8 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
153157

154158
if (is_string($label) && !is_callable($label)) {
155159
$label = new PropertyPath($label);
160+
} elseif (is_string($label) && is_callable($label)) {
161+
@trigger_error('Treating strings as callable is deprecated since version 3.1 and will throw an error in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
156162
}
157163

158164
if ($label instanceof PropertyPath) {
@@ -163,6 +169,8 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
163169

164170
if (is_string($preferredChoices) && !is_callable($preferredChoices)) {
165171
$preferredChoices = new PropertyPath($preferredChoices);
172+
} elseif (is_string($preferredChoices) && is_callable($preferredChoices)) {
173+
@trigger_error('Treating strings as callable is deprecated since version 3.1 and will throw an error in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
166174
}
167175

168176
if ($preferredChoices instanceof PropertyPath) {
@@ -178,6 +186,8 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
178186

179187
if (is_string($index) && !is_callable($index)) {
180188
$index = new PropertyPath($index);
189+
} elseif (is_string($index) && is_callable($index)) {
190+
@trigger_error('Treating strings as callable is deprecated since version 3.1 and will throw an error in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
181191
}
182192

183193
if ($index instanceof PropertyPath) {
@@ -188,6 +198,8 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
188198

189199
if (is_string($groupBy) && !is_callable($groupBy)) {
190200
$groupBy = new PropertyPath($groupBy);
201+
} elseif (is_string($groupBy) && is_callable($groupBy)) {
202+
@trigger_error('Treating strings as callable is deprecated since version 3.1 and will throw an error in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
191203
}
192204

193205
if ($groupBy instanceof PropertyPath) {
@@ -202,6 +214,8 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
202214

203215
if (is_string($attr) && !is_callable($attr)) {
204216
$attr = new PropertyPath($attr);
217+
} elseif (is_string($attr) && is_callable($attr)) {
218+
@trigger_error('Treating strings as callable is deprecated since version 3.1 and will throw an error in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
205219
}
206220

207221
if ($attr instanceof PropertyPath) {

0 commit comments

Comments
 (0)
0