fix function callback in assert callback

This commit is contained in:
TomasVotruba 2020-01-03 18:10:44 +01:00
parent b221a16f06
commit 09c926baf2
2 changed files with 9 additions and 4 deletions

View File

@ -20,7 +20,7 @@ final class AssertChoiceTagValueNode extends AbstractConstraintTagValueNode
public const CLASS_NAME = Choice::class;
/**
* @var mixed[]|null
* @var mixed[]|string|null
*/
private $callback;
@ -30,9 +30,9 @@ final class AssertChoiceTagValueNode extends AbstractConstraintTagValueNode
private $strict;
/**
* @param mixed[]|null $callback
* @param mixed[]|string|null $callback
*/
public function __construct(?array $callback, ?bool $strict, string $annotationContent)
public function __construct($callback, ?bool $strict, string $annotationContent)
{
$this->callback = $callback;
$this->strict = $strict;
@ -44,7 +44,11 @@ final class AssertChoiceTagValueNode extends AbstractConstraintTagValueNode
$contentItems = [];
if ($this->callback) {
$contentItems['callback'] = $this->printArrayItem($this->callback, 'callback');
if (is_array($this->callback)) {
$contentItems['callback'] = $this->printArrayItem($this->callback, 'callback');
} else {
$contentItems['callback'] = sprintf('callback="%s"', $this->callback);
}
}
if ($this->strict !== null) {

View File

@ -26,6 +26,7 @@ final class CompleteImportForPartialAnnotationRector extends AbstractRector
private const DEFAULT_IMPORTS_TO_RESTORE = [
['Doctrine\ORM\Mapping', 'ORM'],
['Symfony\Component\Validator\Constraints', 'Assert'],
['JMS\Serializer\Annotation', 'Serializer'],
];
/**