phpstan

PHPStan - append lists from current and included config file


Let's say I have two configuration NEON files:

config1.neon
parameters:
    excludePaths:
        - path1
config2.neon
includes:
    - "config1.neon"
parameters:
    excludePaths:
        - path2

Resulting configuration (config2.neon) has only excludePath = [path2]. Is there an easy way to append the lists instead of overriding the older one? So that excludePath = [path1, path2]?


Solution

  • The problem I was trying to solve had a different cause. Paths present in config1.neon weren't excluded not because config2.neon would overwrite the list, but because paths in config1.neon were relative to config1.neon's directory (which was different than config2.neon's directory) and didn't exist at all:

    /a/config1.neon
    parameters:
        excludePaths:
            - path1 # results in /a/path1, which does not exist
    
    /b/config2.neon
    includes:
        - "../a/config1.neon"
    parameters:
        excludePaths:
            - path2 # results in /b/path2
    

    Resulting list was:

    - /a/path1 # does not exist, I wanted /b/path1
    - /b/path2