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

api-platform / core / 10773407495

09 Sep 2024 12:41PM UTC coverage: 7.662% (+0.7%) from 6.953%
10773407495

push

github

soyuka
fix: hydra prefix with default context

0 of 1 new or added line in 1 file covered. (0.0%)

7267 existing lines in 233 files now uncovered.

12581 of 164209 relevant lines covered (7.66%)

22.85 hits per line

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

89.29
/src/Metadata/Util/ReflectionClassRecursiveIterator.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\Metadata\Util;
15

16
/**
17
 * Gets reflection classes for php files in the given directories.
18
 *
19
 * @author Antoine Bluchet <soyuka@gmail.com>
20
 *
21
 * @internal
22
 */
23
final class ReflectionClassRecursiveIterator
24
{
25
    private function __construct()
26
    {
27
    }
×
28

29
    public static function getReflectionClassesFromDirectories(array $directories): \Iterator
30
    {
UNCOV
31
        foreach ($directories as $path) {
3✔
UNCOV
32
            $iterator = new \RegexIterator(
3✔
UNCOV
33
                new \RecursiveIteratorIterator(
3✔
UNCOV
34
                    new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS),
3✔
UNCOV
35
                    \RecursiveIteratorIterator::LEAVES_ONLY
3✔
UNCOV
36
                ),
3✔
UNCOV
37
                '/^.+\.php$/i',
3✔
UNCOV
38
                \RecursiveRegexIterator::GET_MATCH
3✔
UNCOV
39
            );
3✔
40

UNCOV
41
            foreach ($iterator as $file) {
3✔
UNCOV
42
                $sourceFile = $file[0];
3✔
43

UNCOV
44
                if (!preg_match('(^phar:)i', (string) $sourceFile)) {
3✔
UNCOV
45
                    $sourceFile = realpath($sourceFile);
3✔
46
                }
47

48
                try {
UNCOV
49
                    require_once $sourceFile;
3✔
50
                } catch (\Throwable) {
×
51
                    // invalid PHP file (example: missing parent class)
52
                    continue;
×
53
                }
54

UNCOV
55
                $includedFiles[$sourceFile] = true;
3✔
56
            }
57
        }
58

UNCOV
59
        $sortedClasses = get_declared_classes();
3✔
UNCOV
60
        sort($sortedClasses);
3✔
UNCOV
61
        $sortedInterfaces = get_declared_interfaces();
3✔
UNCOV
62
        sort($sortedInterfaces);
3✔
UNCOV
63
        $declared = [...$sortedClasses, ...$sortedInterfaces];
3✔
UNCOV
64
        foreach ($declared as $className) {
3✔
UNCOV
65
            $reflectionClass = new \ReflectionClass($className);
3✔
UNCOV
66
            $sourceFile = $reflectionClass->getFileName();
3✔
UNCOV
67
            if (isset($includedFiles[$sourceFile])) {
3✔
UNCOV
68
                yield $className => $reflectionClass;
3✔
69
            }
70
        }
71
    }
72
}
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

© 2024 Coveralls, Inc