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

api-platform / core / 14125569304

28 Mar 2025 09:08AM UTC coverage: 0.0% (-8.5%) from 8.512%
14125569304

Pull #7054

github

web-flow
Merge e654a7d9b into b0fa2291e
Pull Request #7054: fix(symfony): serialization of closure inside the profiler

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

10767 existing lines in 358 files now uncovered.

0 of 47974 relevant lines covered (0.0%)

0.0 hits per line

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

0.0
/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
    /**
26
     * @var array<string, array<class-string, \ReflectionClass>>
27
     */
28
    private static array $localCache;
29

30
    private function __construct()
31
    {
32
    }
×
33

34
    /**
35
     * @param string[] $directories
36
     *
37
     * @return array<class-string, \ReflectionClass>
38
     */
39
    public static function getReflectionClassesFromDirectories(array $directories): array
40
    {
UNCOV
41
        $id = hash('xxh3', implode('', $directories));
×
UNCOV
42
        if (isset(self::$localCache[$id])) {
×
UNCOV
43
            return self::$localCache[$id];
×
44
        }
45

UNCOV
46
        $includedFiles = [];
×
UNCOV
47
        foreach ($directories as $path) {
×
UNCOV
48
            $iterator = new \RegexIterator(
×
UNCOV
49
                new \RecursiveIteratorIterator(
×
UNCOV
50
                    new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
×
UNCOV
51
                    \RecursiveIteratorIterator::LEAVES_ONLY
×
UNCOV
52
                ),
×
UNCOV
53
                '/^(?!.*Test\.php$).+\.php$/i',
×
UNCOV
54
                \RecursiveRegexIterator::GET_MATCH
×
UNCOV
55
            );
×
56

UNCOV
57
            foreach ($iterator as $file) {
×
UNCOV
58
                $sourceFile = $file[0];
×
59

UNCOV
60
                if (!preg_match('(^phar:)i', (string) $sourceFile)) {
×
UNCOV
61
                    $sourceFile = realpath($sourceFile);
×
62
                }
63

64
                try {
UNCOV
65
                    require_once $sourceFile;
×
66
                } catch (\Throwable) {
×
67
                    // invalid PHP file (example: missing parent class)
68
                    continue;
×
69
                }
70

UNCOV
71
                $includedFiles[$sourceFile] = true;
×
72
            }
73
        }
74

UNCOV
75
        $sortedClasses = get_declared_classes();
×
UNCOV
76
        sort($sortedClasses);
×
UNCOV
77
        $sortedInterfaces = get_declared_interfaces();
×
UNCOV
78
        sort($sortedInterfaces);
×
UNCOV
79
        $declared = [...$sortedClasses, ...$sortedInterfaces];
×
UNCOV
80
        $ret = [];
×
UNCOV
81
        foreach ($declared as $className) {
×
UNCOV
82
            $reflectionClass = new \ReflectionClass($className);
×
UNCOV
83
            $sourceFile = $reflectionClass->getFileName();
×
UNCOV
84
            if (isset($includedFiles[$sourceFile])) {
×
UNCOV
85
                $ret[$className] = $reflectionClass;
×
86
            }
87
        }
88

UNCOV
89
        return self::$localCache[$id] = $ret;
×
90
    }
91
}
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