phpcq / coding-standard

This repository holds the C-C-A coding standard definitions for phpcs and phpmd.
BSD 3-Clause "New" or "Revised" License
1 stars 2 forks source link

Rule to check for logic in `config.php` #1

Closed tristanlins closed 8 years ago

tristanlins commented 10 years ago

We should add a rule that check for logic in the config.php.

discordier commented 10 years ago

Which logic? All? Only allow simple assignments? How to determine if it is a config.php in contao context?

tristanlins commented 10 years ago

Only allow simple assignments?

Yes

How to determine if it is a config.php in contao context?

Thats a good question and where is the config.php located? ...

dmolineus commented 10 years ago

I have sometimes a condition between frontend and backbend in the config.php. for example for adding stylesheets for the back end.

Don't see why this would be a bad coding style.

tristanlins commented 10 years ago

Don't see why this would be a bad coding style.

Per definition a configuration must be static, otherwise it is not cacheable. Logic in the internal cache sometimes break your extension. There may be decisions that are "not critical" like the FE/BE decision, but at all I don't want to whitelist something.

Also in the config.php you are still in the bootstrapping process which should not contain such logic. A better way is to use the initializeSystem hook for logic. But in the past - before we had the initializeSystem hook - writing such hacks into the config.php was a working solution.

discordier commented 8 years ago

This is merely now invalid as phpcq is not ccabs anymore and therefore does not handle config.php files.