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

bitExpert / phpstan-magento / 13551485180

26 Feb 2025 07:06PM UTC coverage: 87.989% (-0.3%) from 88.269%
13551485180

push

github

web-flow
Merge pull request #337 from shochdoerfer/fix/ci_pipeline

Fix CI pipeline issues

630 of 716 relevant lines covered (87.99%)

1.77 hits per line

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

94.44
/src/bitExpert/PHPStan/Magento/Autoload/DataProvider/ClassLoaderProvider.php
1
<?php
2
/*
3
 * This file is part of the phpstan-magento package.
4
 *
5
 * (c) bitExpert AG
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
declare(strict_types=1);
11

12
namespace bitExpert\PHPStan\Magento\Autoload\DataProvider;
13

14
use Composer\Autoload\ClassLoader;
15

16
class ClassLoaderProvider
17
{
18
    /**
19
     * @var ClassLoader
20
     */
21
    private $composer;
22

23
    /**
24
     * ClassLoaderProvider constructor.
25
     *
26
     * @param string $magentoRoot
27
     */
28
    public function __construct(string $magentoRoot)
29
    {
30
        $this->composer = new ClassLoader($magentoRoot . '/vendor');
2✔
31
        $autoloadFile = $magentoRoot . '/vendor/composer/autoload_namespaces.php';
2✔
32
        if (is_file($autoloadFile)) {
2✔
33
            /** @var array<string, string> $map */
34
            $map = require $autoloadFile;
2✔
35
            foreach ($map as $namespace => $path) {
2✔
36
                $this->composer->set($namespace, $path);
2✔
37
            }
38
        }
39

40
        $autoloadFile = $magentoRoot . '/vendor/composer/autoload_psr4.php';
2✔
41
        if (is_file($autoloadFile)) {
2✔
42
            /** @var array<string, string> $map */
43
            $map = require $autoloadFile;
2✔
44
            foreach ($map as $namespace => $path) {
2✔
45
                $this->composer->setPsr4($namespace, $path);
2✔
46
            }
47
        }
48

49
        $autoloadFile = $magentoRoot . '/vendor/composer/autoload_classmap.php';
2✔
50
        if (is_file($autoloadFile)) {
2✔
51
            /** @var ?array<string, string> $classMap */
52
            $classMap = require $autoloadFile;
2✔
53
            if (is_array($classMap)) {
2✔
54
                $this->composer->addClassMap($classMap);
2✔
55
            }
56
        }
57
    }
58

59
    /**
60
     * Check if the given class/interface/tait exists in the defined scope.
61
     *
62
     * @param string $classyConstructName
63
     * @return bool
64
     */
65
    public function exists(string $classyConstructName): bool
66
    {
67
        return $this->composer->findFile($classyConstructName) !== false;
2✔
68
    }
69

70
    /**
71
     * Finds the path to the file where the class is defined.
72
     *
73
     * @param string $class The name of the class
74
     * @return string|false The path if found, false otherwise
75
     */
76
    public function findFile($class)
77
    {
78
        return $this->composer->findFile($class);
×
79
    }
80
}
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