This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 270500

Summary: Suggest namespaces from parent folders, psr-4 psr-0 compliant
Product: php Reporter: pmaselkowski
Component: ProjectAssignee: issues@php <issues>
Status: NEW ---    
Severity: normal CC: pmaselkowski
Priority: P3    
Version: Dev   
Hardware: PC   
OS: Linux   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: Example minimal project with above behavior

Description pmaselkowski 2017-04-27 07:39:55 UTC
Story:
1. I have already some namespaced classes in project root, let namespace be Acme
2. I create folder, let's name it Helpers
3. I create right click on this new folder, and choose "New" > "PHP Class", as I wan't to create class Acme\Helpers\StoreLoader, according to PSR-4 namespace rules.
4. Namespace input is empty, which is correct, as there are no classes yet
5. I click arrow of "namespace" input, to check if there are other namespaces

Current behavior:
6. The list is empty

Proposed behavior:
6. Fill list with namespaces from parent folders
6.a Have on top of the list, or directly in input: "Parent\Namespace" + "\CurrentFolderName"

Why?
Will be easier and less error prone to just add last namespace part "Helpers", or choose guessed one.
Folder to namespace mapping is compatible with PHP's psr-4 and psr-0 namespace/autoloader standard.
Comment 1 pmaselkowski 2017-04-27 07:45:33 UTC
Created attachment 164197 [details]
Example minimal project with above behavior