• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 6690762601

30 Oct 2023 09:24AM UTC coverage: 67.319% (+0.02%) from 67.301%
6690762601

push

github

web-flow
ci: fix PHPUNIT (#5907)

* ci: fix phpunit


???

* Unset handler_id for symfony 6.3+

* Fix serializer configuration for PHP 8.1 (dev)

* Fix https://github.com/api-platform/api-platform/issues/2437

* Fix excepted deprecation in swagger


Trigger deprecation to fit tests. Can change test if needed


forgot semicolon


try fix deprecation

* remove copied WebTestCase to fix 8.1 dev

PR https://github.com/symfony/symfony/pull/32207 got merged

* fix no deprecation

* try tag legacy to valide


add a bc layer for reworked profiler UI

* fix warning about deprecated method


ensure method exists

* skip an exceptDeprecation, this case fails for a particular CI run

* remove uneccesary changes

* change BC deprecation system for doctrine

* fix some deprecations about validation html mode and attributes for recent sf

* fix doctrine lexer deprecations

* fix bootstrap missing

* improve doc for sf 6


f


Fix tiny bug & deprecation


--

* fix possible deprecation on 7.4

* Update ci.yml

* Update ci.yml

15610 of 23188 relevant lines covered (67.32%)

10.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Doctrine/Odm/Filter/NumericFilter.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Doctrine\Odm\Filter;
15

16
use ApiPlatform\Doctrine\Common\Filter\NumericFilterTrait;
17
use ApiPlatform\Metadata\Operation;
18
use Doctrine\ODM\MongoDB\Aggregation\Builder;
19
use Doctrine\ODM\MongoDB\Types\Type as MongoDbType;
20

21
/**
22
 * Filters the collection by numeric values.
23
 *
24
 * Filters collection by equality of numeric properties.
25
 *
26
 * For each property passed, if the resource does not have such property or if
27
 * the value is not numeric, the property is ignored.
28
 *
29
 * @author Amrouche Hamza <hamza.simperfit@gmail.com>
30
 * @author Teoh Han Hui <teohhanhui@gmail.com>
31
 * @author Alan Poulain <contact@alanpoulain.eu>
32
 *
33
 * @final
34
 */
35
class NumericFilter extends AbstractFilter
36
{
37
    use NumericFilterTrait;
38

39
    /**
40
     * Type of numeric in Doctrine.
41
     */
42
    public const DOCTRINE_NUMERIC_TYPES = [
43
        MongoDbType::INT => true,
44
        MongoDbType::INTEGER => true,
45
        MongoDbType::FLOAT => true,
46
    ];
47

48
    /**
49
     * {@inheritdoc}
50
     */
51
    protected function filterProperty(string $property, $value, Builder $aggregationBuilder, string $resourceClass, Operation $operation = null, array &$context = []): void
52
    {
53
        if (
54
            !$this->isPropertyEnabled($property, $resourceClass) ||
×
55
            !$this->isPropertyMapped($property, $resourceClass) ||
×
56
            !$this->isNumericField($property, $resourceClass)
×
57
        ) {
58
            return;
×
59
        }
60

61
        $values = $this->normalizeValues($value, $property);
×
62
        if (null === $values) {
×
63
            return;
×
64
        }
65

66
        $matchField = $property;
×
67

68
        if ($this->isPropertyNested($property, $resourceClass)) {
×
69
            [$matchField] = $this->addLookupsForNestedProperty($property, $aggregationBuilder, $resourceClass);
×
70
        }
71

72
        if (1 === \count($values)) {
×
73
            $aggregationBuilder->match()->field($matchField)->equals($values[0]);
×
74
        } else {
75
            $aggregationBuilder->match()->field($matchField)->in($values);
×
76
        }
77
    }
78

79
    /**
80
     * {@inheritdoc}
81
     */
82
    protected function getType(string $doctrineType = null): string
83
    {
84
        if (null === $doctrineType) {
×
85
            return 'string';
×
86
        }
87

88
        if (MongoDbType::FLOAT === $doctrineType) {
×
89
            return 'float';
×
90
        }
91

92
        return 'int';
×
93
    }
94
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc