deptrac icon indicating copy to clipboard operation
deptrac copied to clipboard

PHP Config: LayerCollector should reference layer by variable

Open patrickkusebauch opened this issue 2 years ago • 2 comments

Currently it is by the string representation of the layer name.

patrickkusebauch avatar May 25 '23 17:05 patrickkusebauch

That's a good idea. But one disadvantage would be, that you have to define the LayerCollectorConfig add the end (should be fine with a note in the documentation), if you want to reference the other layers by the variable.

So should be have both options?

$secondLayer = Layer::withName('second')->collectors(
    // by string
    LayerConfig::create('first'),
);

$firstLayer = Layer::withName('first')->collectors(
    DirectoryConfig::create('./src'),
);

$thirdLayer = Layer::withName('thirs')->collectors(
    // by variable
    LayerConfig::create($firstLayer),
);

gennadigennadigennadi avatar Jun 07 '23 09:06 gennadigennadigennadi

Yeah, absolutely. What I like about this approach is that it would make it much harder to make cyclic layer dependencies. I have more notes on PHP Config ergonomics as I just ported a relatively large project from YAML to PHP in the past few days.

patrickkusebauch avatar Jun 07 '23 19:06 patrickkusebauch