ZS10 Catching multiple exceptions

General discussion on Zend Studio

Moderator: natalia_b_zend

ZS10 Catching multiple exceptions

Postby abxccd on Sun Feb 17, 2013 4:39 am

I have a bit of PHP code like this:

Code: Select all
try {
  //Do some stuff
}
catch (LogicException $e) {
  //Deal with exception
}
catch (AnotherTypeOfException $e) {
  //Deal with exception
}
catch (Exception $e) {
  //Deal with exception
}


From my understanding, the code above should be valid, but ZS10 is saying "Cannot redeclare field $e in type MyClass" for the second and third catches. Is this a bug in ZS?
abxccd
 
Posts: 9
Joined: Tue Feb 15, 2011 12:37 pm

Re: ZS10 Catching multiple exceptions

Postby zhaozhongwei on Mon Feb 18, 2013 2:43 pm

Hi,

I am using the following code,and enable the semantic analysis:
<?php

class MyClass {
function test() {
try {
//Do some stuff
}
catch (LogicException $e) {
//Deal with exception
}
catch (AnotherTypeOfException $e) {
//Deal with exception
}
catch (Exception $e) {
//Deal with exception
}
}
}


But I did not got the error.can you send me your whole file?
Thanks!
zhaozhongwei
 
Posts: 2
Joined: Mon Aug 20, 2012 8:28 am

Re: ZS10 Catching multiple exceptions

Postby abxccd on Wed Feb 20, 2013 4:17 am

After more testing, it turns out this bug is only trigged when a namespace is used:

Code: Select all
<?php
namespace mynamespace;
try {
//Do stuff
}
catch (LogicException $e) {
  //do stuff
}
catch (DomainException $e) {
   //do stuff
}
catch (Exception $e) {
   //do stuff
}


I hope this can get fixed soon, as it is quite annoying in modern projects which uses namespaces.
abxccd
 
Posts: 9
Joined: Tue Feb 15, 2011 12:37 pm


Return to Zend Studio

Who is online

Users browsing this forum: No registered users and 7 guests