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

sanmai / pipeline / 16436877530

22 Jul 2025 06:47AM UTC coverage: 98.695% (-1.3%) from 100.0%
16436877530

push

github

web-flow
Extend TypeInferenceTest (#227)

165 of 173 new or added lines in 6 files covered. (95.38%)

605 of 613 relevant lines covered (98.69%)

336.52 hits per line

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

76.92
/src/PHPStan/CallbackResolver.php
1
<?php
2

3
/**
4
 * Copyright 2017, 2018 Alexey Kopytko <alexey@kopytko.com>
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18

19
declare(strict_types=1);
20

21
namespace Pipeline\PHPStan;
22

23
use PhpParser\Node\Arg;
24
use PhpParser\Node\Expr\FuncCall;
25
use PhpParser\Node\Scalar\String_;
26
use PHPStan\Type\Type;
27

28
/**
29
 * Resolves callback arguments to their target types.
30
 */
31
class CallbackResolver
32
{
33
    public function __construct(
34
        private FilterTypeNarrowingHelper $helper
35
    ) {}
8✔
36

37
    /**
38
     * Resolve a callback argument to its target type.
39
     *
40
     * @return Type|null The type that the callback filters for, or null if unknown
41
     */
42
    public function resolveCallbackType(?Arg $callbackArg): ?Type
43
    {
44
        if (null === $callbackArg) {
8✔
NEW
45
            return null;
×
46
        }
47

48
        $callbackExpr = $callbackArg->value;
8✔
49

50
        // Handle string callbacks (e.g., 'is_string')
51
        if ($callbackExpr instanceof String_) {
8✔
52
            $functionName = $this->helper->extractFunctionNameFromStringCallback($callbackExpr);
4✔
53
            if (null !== $functionName) {
4✔
NEW
54
                return $this->helper->getTargetTypeForFunction($functionName);
×
55
            }
56
        }
57

58
        // Handle first-class callable syntax (e.g., is_string(...))
59
        if ($callbackExpr instanceof FuncCall) {
8✔
60
            $functionName = $this->helper->extractFunctionNameFromFirstClassCallable($callbackExpr);
4✔
61
            if (null !== $functionName) {
4✔
NEW
62
                return $this->helper->getTargetTypeForFunction($functionName);
×
63
            }
64
        }
65

66
        return null;
8✔
67
    }
68
}
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