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

eliashaeussler / phpstan-config / 22739160447

05 Mar 2026 10:10PM UTC coverage: 64.364% (-32.3%) from 96.654%
22739160447

Pull #132

github

eliashaeussler
[FEATURE] Add custom rule to compare composer.json and ext_emconf.php
Pull Request #132: [FEATURE] Add custom rule to compare composer.json and ext_emconf.php

153 of 371 new or added lines in 11 files covered. (41.24%)

410 of 637 relevant lines covered (64.36%)

4.55 hits per line

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

0.0
/src/Resource/Local/ExtEmConf.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Composer package "eliashaeussler/phpstan-config".
7
 *
8
 * Copyright (C) 2023-2026 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace EliasHaeussler\PHPStanConfig\Resource\Local;
25

26
use EliasHaeussler\PHPStanConfig\Enums;
27
use EliasHaeussler\PHPStanConfig\Resource;
28
use PhpParser\Node;
29
use Symfony\Component\Filesystem;
30

31
/**
32
 * ExtEmConf.
33
 *
34
 * @author Elias Häußler <elias@haeussler.dev>
35
 * @license GPL-3.0-or-later
36
 */
37
final readonly class ExtEmConf
38
{
39
    public string $filename;
40

NEW
41
    public function __construct(
×
42
        private string $currentWorkingDirectory,
43
    ) {
NEW
44
        $this->filename = Filesystem\Path::join($this->currentWorkingDirectory, 'ext_emconf.php');
×
45
    }
46

47
    /**
48
     * @return list<Resource\EmConfRelation>
49
     */
NEW
50
    public function extractRelations(Node\Expr\Array_ $array, Enums\PackageRelation $relation): array
×
51
    {
NEW
52
        foreach ($array->items as $item) {
×
NEW
53
            if (!$item->key instanceof Node\Scalar\String_ || 'constraints' !== $item->key->value) {
×
NEW
54
                continue;
×
55
            }
56

NEW
57
            if (!$item->value instanceof Node\Expr\Array_) {
×
NEW
58
                return [];
×
59
            }
60

NEW
61
            foreach ($item->value->items as $relations) {
×
NEW
62
                if (!$relations->key instanceof Node\Scalar\String_ || $relations->key->value !== $relation->forExtEmConf()) {
×
NEW
63
                    continue;
×
64
                }
65

NEW
66
                if (!$relations->value instanceof Node\Expr\Array_) {
×
NEW
67
                    return [];
×
68
                }
69

NEW
70
                $result = [];
×
71

NEW
72
                foreach ($relations->value->items as $relationItem) {
×
NEW
73
                    if (!$relationItem->key instanceof Node\Scalar\String_ || !$relationItem->value instanceof Node\Scalar\String_) {
×
NEW
74
                        continue;
×
75
                    }
76

NEW
77
                    $result[] = new Resource\EmConfRelation(
×
NEW
78
                        $relationItem->key->value,
×
NEW
79
                        $relationItem->value->value,
×
NEW
80
                        $relation,
×
NEW
81
                        $relationItem->getLine(),
×
NEW
82
                    );
×
83
                }
84

NEW
85
                return $result;
×
86
            }
87
        }
88

NEW
89
        return [];
×
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