Skip to content

fix ImageType NotBlank constraint#237

Open
ilaria-orlando wants to merge 1 commit into
masterfrom
fix-image-type-not-blank-constraint
Open

fix ImageType NotBlank constraint#237
ilaria-orlando wants to merge 1 commit into
masterfrom
fix-image-type-not-blank-constraint

Conversation

@ilaria-orlando

@ilaria-orlando ilaria-orlando commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Bug fix

Passing an array of options to a Constraint is deprecated

Summary by Sourcery

Bug Fixes:

  • Replace deprecated array-based options in the NotBlank constraint with a named argument to ensure compatibility with newer Symfony validation APIs.

@sourcery-ai

sourcery-ai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Replaces deprecated array-based NotBlank constraint options with named argument syntax to fix a deprecation in ImageType.

File-Level Changes

Change Details Files
Stop using deprecated array options when instantiating the NotBlank constraint for required image uploads.
  • Instantiate NotBlank using the named argument 'message' instead of passing an options array.
  • Preserve the existing required_image_error option as the message value for the NotBlank constraint.
src/Form/Type/ImageType.php

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/Form/Type/ImageType.php" line_range="52" />
<code_context>
                         $fileFieldOptions['constraints'] = [
                             new NotBlank(
-                                ['message' => $options['required_image_error']]
+                                message: $options['required_image_error']
                             ),
                         ];
</code_context>
<issue_to_address>
**issue (bug_risk):** Using a named argument here does not match NotBlank's constructor signature and will break at runtime.

`NotBlank`’s constructor takes an options array as its first (and only) argument, so `['message' => $options['required_image_error']]` was correct. Using `message:` as a named parameter does not match the constructor and will cause a named-parameter runtime error. Please either revert to the array form or change this to `new NotBlank(['message' => $options['required_image_error']])` to keep the behavior intact.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

$fileFieldOptions['constraints'] = [
new NotBlank(
['message' => $options['required_image_error']]
message: $options['required_image_error']

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Using a named argument here does not match NotBlank's constructor signature and will break at runtime.

NotBlank’s constructor takes an options array as its first (and only) argument, so ['message' => $options['required_image_error']] was correct. Using message: as a named parameter does not match the constructor and will cause a named-parameter runtime error. Please either revert to the array form or change this to new NotBlank(['message' => $options['required_image_error']]) to keep the behavior intact.

@jonasdekeukelaere

Copy link
Copy Markdown
Member

@ilaria-orlando fix het bij FileType ook maar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants