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

donatj / php-dnf-solver / 14372126470

10 Apr 2025 04:10AM UTC coverage: 98.347%. Remained the same
14372126470

push

github

web-flow
Merge pull request #14 from donatj/donatj-patch-1

Test in PHP 8.4

119 of 121 relevant lines covered (98.35%)

11.65 hits per line

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

100.0
/src/Types/CallableType.php
1
<?php
2

3
namespace donatj\PhpDnfSolver\Types;
4

5
use donatj\PhpDnfSolver\NestedDnfTypeInterface;
6
use donatj\PhpDnfSolver\SingularDnfTypeInterface;
7
use donatj\PhpDnfSolver\Traits\UnwrapTrait;
8

9
/**
10
 * Represents a "callable" type
11
 *
12
 * This includes:
13
 * - callable
14
 * - Closure
15
 * - Invokable classes
16
 */
17
class CallableType implements SingularDnfTypeInterface {
18

19
        use UnwrapTrait;
20

21
        public function dnf() : string {
22
                return 'callable';
4✔
23
        }
24

25
        public function isSatisfiedBy( SingularDnfTypeInterface|NestedDnfTypeInterface $value ) : bool {
26
                $value = $this->unwrap($value);
9✔
27
                if( !$value ) {
9✔
28
                        return false;
2✔
29
                }
30

31
                if( $value instanceof self ) {
7✔
32
                        return true;
3✔
33
                }
34

35
                if( $value instanceof UserDefinedType ) {
4✔
36
                        return $this->isClassInvokable($value->getTypeName());
3✔
37
                }
38

39
                return false;
1✔
40
        }
41

42
        /**
43
         * @param class-string $className
44
         */
45
        private function isClassInvokable( string $className ) : bool {
46
                return (new \ReflectionClass($className))->hasMethod('__invoke');
3✔
47
        }
48

49
        public function getTypeName() : string {
50
                return 'callable';
3✔
51
        }
52

53
        public function count() : int {
54
                return 1;
1✔
55
        }
56

57
}
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