Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 315681

Summary: code assisting in a catch statement does not take in account namespaces
Product: z_Archived Reporter: aikeleer
Component: PDTAssignee: PHP Core <php.core-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: silviya, zhaozhongwei, zulus
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows Server 2003   
Whiteboard:

Description aikeleer CLA 2010-06-03 17:28:56 EDT
Build Identifier: 20100527-0614

When coding inside a Namespace and using a try{ } catch-block, code assist forgets my namespace. 

Reproducible: Always

Steps to Reproduce:
For example:
namespace foo;

This should be suggested at the catch phrase:
try
{
{
catch(\Exception $e)
{
}

But this is suggested:
try
{
}
catch(Exception $e)
{
}

While this results in a fatal error.
Comment 1 Zhongwei Zhao CLA 2010-06-03 21:15:22 EDT
Hi

Can you describe the steps to reproduce this,for example

1.have the following content in php
{
}
catch(\Exception| $e)//cursor
{
}

2 calll CA
3 Results in a fatal error.


Thanks
Comment 2 Zhongwei Zhao CLA 2010-06-03 23:20:08 EDT
Hi

I guess when you run the code you get fatal error ,right?
Comment 3 aikeleer CLA 2010-06-04 15:40:09 EDT
Example code:

This is a working version:
<?php

namespace example;

class Bla
{
	function __construct()
	{
		try
		{
			// something which throws an Exception
		}
		catch(\Exception $e)
		{
			echo "bla";
		}
	}
}
$bla = new Bla();

?>

Now for the Assist functionality:

I type
<?php

namespace exmaple;

class Bla
{
function __construct()
{
try
{
// function which throws exception
}
catch ([CURSOR, now type ctrl+space, choose Exception, press Enter]

The suggestion puts a normal 'Exception' there, while it should be a '\Exception'.

I really hope this is a bit more clear. :)
Comment 4 Zhongwei Zhao CLA 2011-05-17 02:45:40 EDT
fixed in head
Comment 5 Zhongwei Zhao CLA 2011-06-14 23:56:41 EDT
reopen it,because now it only works for the code:
<?php

namespace exmaple;

class Bla
{
function __construct()
{
try
{
// function which throws exception
}
catch ([CURSOR, now type ctrl+space, choose Exception, press Enter] $e){
         
      }
   }
}

?>
Comment 6 Dawid Pakula CLA 2014-06-02 04:59:27 EDT
This works correctly with 3.3.0
Comment 7 Sylvia Tancheva CLA 2015-05-29 11:29:50 EDT
Verified. Closing