Hi All,
I’m struggling to get my head around how practically coding standards work in the context of Sage and my own development environment.
I’ve now built quite a few websites with Sage9, I use PHPStorm as my IDE. I’m aware of various coding standards; phpcs
, psr-0
, psr-2
and psr-4
. Plus there is terminology like psr-4 autoloading
, code_sniffing
and so on.
Am I right in thinking that Sage uses psr-2 for code and psr-4 autoloading? Can anyone explain the difference - are these two different things?
What is psr-2 exactly, is it just about the number of spaces for indents, end of line and trailing whitespace as defined in .editorconfig or is it more than that?
Sometimes in my IDE when editing .php or .js files I get warning messages about the number of spaces used for indents, I usually just click OK to accept it’s recommendation but would this be coming from PHPStorm inperpreting the .editorconfig
file?
Finally, what should I be doing about testing? I have noticed that in composer.json, I have the following:
"require-dev": {
"squizlabs/php_codesniffer": "^2.8.0",
"roots/sage-installer": "~1.3"
},
"scripts": {
"test": ["phpcs"],
"post-create-project-cmd": [
"Roots\\Sage\\Installer\\ComposerScript::postCreateProject"
]
}
What relation does this have if any to coding standards and testing and how should I be using something like php_codesniffer?
Thanks in advance for any help with this.
Kevin