You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, all formatters use a static variable (or constant) to indicate support for specific languages.
This works, but has some performance penalties, because (in worst cases) all formatters are autoloaded at runtime just to check if a specific language is supported.
My suggestion would be some kind of mapping/config file.
Example:
The text was updated successfully, but these errors were encountered:
asccc
changed the title
Use language mapping instead of constant/static variable in formatters
Use config-file instead of constant/static variable in formatters for supported languages
Jul 10, 2020
So you're thinking about a loader class that checks the config and then loads the formatter class on demand?
Is that something we would load into env at start?
Sounds good.
Some thoughts (not sure)
File Extensions
With that change we could think about adding file extension mappings to it as well
Formatter Names in the config
The formatter name probably should have a fully qualified class string (with namespace) in case we want to use external packages/plugins
Config file format
I'm split between putting it into a separate php/yaml or having the mappings inside the config handling class. The external file makes it more obvious that it's a config file, but the mapping is strongly coupled with the code formatter class names anyways. If it's all in the class, we don't have to load an extra file and the formatter class strings could be generated. But I don't know what's better regarding performance.
Currently, all formatters use a static variable (or constant) to indicate support for specific languages.
This works, but has some performance penalties, because (in worst cases) all formatters are autoloaded at runtime just to check if a specific language is supported.
My suggestion would be some kind of mapping/config file.
Example:
The text was updated successfully, but these errors were encountered: