This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Bundle/FrameworkBundle/Templating
Fabien Potencier b74a887cd9 minor #9487 unify constructor initialization style throughout symfony (Tobion)
This PR was merged into the master branch.

Discussion
----------

unify constructor initialization style throughout symfony

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | n/a

In almost all classes symfony uses property initialization when the value is static. Constructor initialization is only used for things that actually have logic, like passed parameters or dynamic values. IMHO it makes the code much more readable because property definition, phpdoc and default value is in one place. Also one can easily see what the constructor implements for logic like overridden default value of a parent class. Otherwise the real deal is just hidden behind 10 property initializations. One more advantage is that it requires less code. As you can see, the code was almost cut in half (210 additions and 395 deletions).
I unified it accordingly across symfony. Sometimes it was [not even consistent within one class](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Config/Definition/BaseNode.php#L32). At the same time I recognized some errors like missing parent constructor call, or undefined properties or private properties that are not even used.

I then realized that a few Kernel tests were not passing because they were deeply implementation specific like modifying booted flag with a custom `KernelForTest->setIsBooted();`. I improved and refactored the kernel tests in the __second commit__.

__Third commit__ unifies short ternary operator, e.g. `$foo ?: new Foo()`. __Forth commit__ unifies missing parentheses, e.g. `new Foo()`.

Commits
-------

077a089 unify missing parentheses
2888594 unify short ternary operator
2a9daff [HttpKernel] better written kernel tests
111ac18 unify constructor initialization style throughout symfony
2013-11-22 18:42:00 +01:00
..
Asset Fix some annotates 2013-09-19 11:36:05 +02:00
Helper Fixed typos 2013-11-09 12:55:32 +01:00
Loader [Templating] fix logic regarding template references and many phpdocs 2013-10-01 14:37:05 +02:00
Debugger.php [Templating] deprecate DebuggerInterface 2013-09-04 21:57:45 +02:00
DelegatingEngine.php [Templating] fix logic regarding template references and many phpdocs 2013-10-01 14:37:05 +02:00
EngineInterface.php [Templating] fix logic regarding template references and many phpdocs 2013-10-01 14:37:05 +02:00
GlobalVariables.php [FrameworkBundle] use the new request_stack object in the GlobalVariables object 2013-11-20 13:37:49 +01:00
PhpEngine.php [Templating] fix logic regarding template references and many phpdocs 2013-10-01 14:37:05 +02:00
TemplateFilenameParser.php [Templating] fix logic regarding template references and many phpdocs 2013-10-01 14:37:05 +02:00
TemplateNameParser.php unify constructor initialization style throughout symfony 2013-11-11 19:40:07 +01:00
TemplateReference.php Improved performance when assetic's use_controller is enabled 2011-07-15 20:52:23 -05:00
TimedPhpEngine.php [Templating] fix logic regarding template references and many phpdocs 2013-10-01 14:37:05 +02:00