Hi All,
I'm just exploring the issues raised by scrutinizer. It raise issues like, variable is not initialized. Have a look at issue [0], complaining on code segment [1].
Personally I like to initialize variables, before using it, even a value is assigning at some point of the execution path. In this case we can initialized it like $x=array('foo');
As I remember Marc mentioned different thought on this kind of situation (at the LinuxTag booth). You may have good thoughts we should know.
So what we should do for this kind of issue ? Just ignore them since PHP does not force, or fix them ? Appreciate your thoughts.
[0] : http://goo.gl/HNW8Be [1] : http://goo.gl/vUj25O
Regards !
2014-05-17 14:26 GMT+02:00 Chanaka Dharmarathna pe.chanaka.ck@gmail.com:
Hi All,
I'm just exploring the issues raised by scrutinizer. It raise issues like, variable is not initialized. Have a look at issue [0], complaining on code segment [1].
Personally I like to initialize variables, before using it, even a value is assigning at some point of the execution path. In this case we can initialized it like $x=array('foo');
As I remember Marc mentioned different thought on this kind of situation (at the LinuxTag booth). You may have good thoughts we should know.
So what we should do for this kind of issue ? Just ignore them since PHP does not force, or fix them ? Appreciate your thoughts.
[0] : http://goo.gl/HNW8Be [1] : http://goo.gl/vUj25O
Regards !
Chanaka Dharmarathna
Hi,
I think this is better to "fix" them. Because it is always difficult to know the behavior of PHP in this case. And what could happen in next version if they decide to change this behavior? I really don't like to let IT decides itself how it should behave. :)
If I find this kind of code, I wouldn't ask and fix it immediatly.
Hugues.
On Sat, May 17, 2014 at 5:56 PM, Chanaka Dharmarathna < pe.chanaka.ck@gmail.com> wrote:
Hi All,
I'm just exploring the issues raised by scrutinizer. It raise issues like, variable is not initialized. Have a look at issue [0], complaining on code segment [1].
Personally I like to initialize variables, before using it, even a value is assigning at some point of the execution path. In this case we can initialized it like $x=array('foo');
As I remember Marc mentioned different thought on this kind of situation (at the LinuxTag booth). You may have good thoughts we should know.
So what we should do for this kind of issue ? Just ignore them since PHP does not force, or fix them ? Appreciate your thoughts.
Hi, IMHO, Yes, we should initialize them as per following convention (as it is a good practice):
$booleans = false; $integers = 0; $floats = 0.0; $strings = ''; $array = array();
[0] : http://goo.gl/HNW8Be [1] : http://goo.gl/vUj25O
Regards !
Chanaka Dharmarathna *http://chanakaindrajith.blogspot.com/*http://chanakaindrajith.blogspot.com/
Le 2014-05-17 08:26, Chanaka Dharmarathna a écrit :
Hi All,
I'm just exploring the issues raised by scrutinizer. It raise issues like, variable is not initialized. Have a look at issue [0], complaining on code segment [1].
Personally I like to initialize variables, before using it, even a value is assigning at some point of the execution path. In this case we can initialized it like $x=array('foo');
As I remember Marc mentioned different thought on this kind of situation (at the LinuxTag booth). You may have good thoughts we should know.
Hi Chanaka, I don't remember talking about this situation, but talking about another kind of issue: when scrutinizer reports that some initialization is not needed because, further in the code, there is a if/else pair that initializes the same variable in all situations.
So what we should do for this kind of issue ? Just ignore them since PHP does not force, or fix them ? Appreciate your thoughts.
Let's make scrutinizer happy ;)
[0] : http://goo.gl/HNW8Be [1] : http://goo.gl/vUj25O
Hi Chanaka, I don't remember talking about this situation, but talking about another kind of issue: when scrutinizer reports that some initialization is not needed because, further in the code, there is a if/else pair that initializes the same variable in all situations.
-- Marc Delisle
Oh yes, this one is a bit tricky. For human, sure, it's easier to be sure that a variable is initialised if you define it, even if all cases will define it also.
Hugues.
On Sat, May 17, 2014 at 8:16 PM, Hugues Peccatte hugues.peccatte@gmail.comwrote:
Hi Chanaka,
I don't remember talking about this situation, but talking about another kind of issue: when scrutinizer reports that some initialization is not needed because, further in the code, there is a if/else pair that initializes the same variable in all situations.
-- Marc Delisle
Oh yes, this one is a bit tricky. For human, sure, it's easier to be sure that a variable is initialised if you define it, even if all cases will define it also.
Hi,
Thanks for your thoughts. So we can fix this kind of issues :)
Regards !