Skip to content

Move all implicit path assumptions to explicit input via a PathList class #16

@ralflang

Description

@ralflang

Factor out implicit assumptions from the individual tasks:

Build a class InstallPathList implements Traversable, including previously hardcoded assumptions:

  • string rootPackageDir
  • vendorDir default to packageRootDir . '/vendor'
  • binDir (default to vendorDir . '/bin')
  • webRootDir (default to rootPackageDir . '/web')
  • configDir (default to rootPackageDir . '/var/config')
  • configDistDir
  • staticDir (default to webRootDir/static)
  • tmpDir (default to packageRootDir / var/tmp
  • vfsDir (default to packageRootDir / var/vfs)
  • cacheDir (default to packageRootDir / var/cache)
  • logDir (default to packageRootDir / var/log)
  • sessionDir (default to packageRootDir / var/session)

Make variables private, add getters (no __get), add an iterator and a dumpArray() method.
Make the constructor explicitly name the variables. Don't worry about the impractical constructor.

We cannot use Initializers before PHP 8.1 - add a static defaultsFromRootPackageDir(string rootPackageDir) that constructs a defaults array.

Add a static fromArray method that merges an input array with the defaultsFromRootPackageDir and runs the array keys against the constructor. The input array must have at least the rootPackageDir key.

We get a class that assembles defaults from a single root string or allows to pass as many details as wanted - and once we switch baseline to PHP 8.1 we can add convenience without a BC break.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions