erusev / parsedown

Better Markdown Parser in PHP
https://parsedown.org
MIT License
14.69k stars 1.12k forks source link

Add mutable configurable #768

Closed aidantwoods closed 4 years ago

aidantwoods commented 4 years ago

Configurables are designed to be immutable because it makes working with them and reasoning about their values much easier (see: https://github.com/erusev/parsedown/pull/708#issuecomment-576026421), however in some very special cases mutability might be required to create special behaviours (envisioned use case for this is mostly where definitions are recorded and need to be accessible by the whole parsing tree).

To quote the embedded description for the MutableConfigurable interface:

Beware that the values of MutableConfigurables are NOT stable. Values SHOULD be accessed as close to use as possible. Parsing operations sharing the same State SHOULD NOT be triggered between where values are read and where they need to be relied upon.