Adding the possibility to use BackedEnumFilter on values 0, -1, -2 etc.

Open Beginner friendly
#8,475 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
php

Research direction

No file or test is named in the issue. Start by locating BackedEnumFilter and its normalizeValue path, then reproduce filtering with backed enum values 0, -1, and -2. Done means those values are accepted without being discarded, with the behavior covered by the filter's existing tests.

Written by the indexing model from the issue text.

Description

Description
It is currently not possible to use the BackedEnumFilter on values below 1, currently i have a enum class starting at 0. I cannot use the BackedEnumFilter for this currently.

Example

$values = is_array($value) ? $value : [$value];

    $normalizedValues = array_values(array_filter(
        array_map(fn ($value) => $this->normalizeValue($value, $property), $values),
        static fn ($value) => null !== $value,
    ));
Dominant language
PHP
Stars
2.6k
Forks
982
Avg merge
1d 23h
Merged PRs (30d)
42

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from api-platform/core

All issues in api-platform/core

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.