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 243744 - Wrong new line behaviour for namespaces
Summary: Wrong new line behaviour for namespaces
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 8.0
Hardware: All All
: P3 normal with 5 votes (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-10 22:27 UTC by av3nger
Modified: 2016-04-05 01:45 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
patch for proposal (7.69 KB, patch)
2016-04-03 04:58 UTC, junichi11
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description av3nger 2014-04-10 22:27:27 UTC
Since NetBeans 8.0 it's not possible to write the namespace in the line after the php open tag when using the formatting feature. Did work in 7.4.

In the formatting options I selected Language: PHP and Category: Blank Lines.

When I set "Before Namespace" and "After Open Tag" to 0, I get:

<?php namespace MyProject;

When I set one of these values to 1, I get:

<?php

namespace MyProject;

But I want this (without a blank line):

<?php
namespace MyProject;

It seems that this isn't possible anymore.
Comment 1 Vladimir Riha 2014-04-11 06:15:28 UTC
Reproducible

Product Version: NetBeans IDE Dev (Build 201404100001)
Java: 1.8.0; Java HotSpot(TM) Client VM 25.0-b70
Runtime: Java(TM) SE Runtime Environment 1.8.0-b132
System: Linux version 3.2.0-60-generic-pae running on i386; UTF-8; en_US (nb)
Comment 2 ayanozturk 2014-08-22 11:21:57 UTC
Trying to fix auto formatting according to PSR-2 standards. Because of this bug, namespace part can not be configured like it is explained in: http://www.php-fig.org/psr/psr-2/

<?php
namespace Vendor\Package;

class ClassName
{
    public $foo = null;
}
Comment 3 junichi11 2016-04-03 04:58:07 UTC
Created attachment 159105 [details]
patch for proposal

This is related to the issue 235710.
I think that it is the special case for Laravel4. So, if Blank Lines settings for both "After Open PHP Tag" and "Before Namespace" are 0, it should be formatted for PSR-2 by default.

My proposal:
Add the new option("Between Open PHP Tag and Namespace") to "Spaces". 
But it may not be a proper place...

Thanks.
Comment 4 junichi11 2016-04-03 05:00:48 UTC
I've created a patch for proposal.

Tomas, could you please review it when you can make time?

Thanks!
Comment 5 Tomas Mysik 2016-04-04 07:26:57 UTC
Will apply it, thanks a lot Junichi, as always!
Comment 6 Tomas Mysik 2016-04-04 07:39:44 UTC
Patch applied, thanks a lot, Junichi!

http://hg.netbeans.org/web-main/rev/4ee4f3cc55ed
Comment 7 Quality Engineering 2016-04-05 01:45:11 UTC
Integrated into 'main-silver', will be available in build *201604050001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/4ee4f3cc55ed
User: Tomas Mysik <tmysik@netbeans.org>
Log: #243744 - Wrong new line behaviour for namespaces

Patch contributed by junichi11@netbeans.org.