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 251240 - Improper indentation in anonymous functions
Summary: Improper indentation in anonymous functions
Status: RESOLVED WORKSFORME
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 8.0.2
Hardware: All All
: P3 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-17 16:50 UTC by antoniocs
Modified: 2016-08-12 10:42 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description antoniocs 2015-03-17 16:50:42 UTC
I have a simple anonymous function in an array_map, this is how I have it formatted:

         $ids = array_map(
                function($item) {
                    return $item['match'];
                }, $record);

Here is how netbeans formats it:

       $ids = array_map(
                function($item) {
            return $item['match'];
        }, $record);

Is it not possible to set the auto formater to do something like what I have??
Comment 1 artur_m 2015-03-24 16:41:44 UTC
Another example:

function bar()
{
	return
		[
			function()
			{
				echo [];
			}
		];
	}
Comment 2 Tomas Mysik 2016-02-12 09:00:36 UTC
Do you mean formatting or indentation?

Thanks.
Comment 3 Tomas Mysik 2016-08-12 10:42:54 UTC
(In reply to antoniocs from comment #0)
> Is it not possible to set the auto formater to do something like what I
> have??

Perhaps the best way is to write it this way:

$ids = array_map(function($item) {
    return $item['match'];
}, $record);

(In reply to artur_m from comment #1)
> Another example:
> 
> function bar()
> {
> 	return
> 		[
> 			function()
> 			{
> 				echo [];
> 			}
> 		];
> 	}

Sorry, no idea what you mean. Please, next time write exact steps, the actual and expected nehavior.

Thanks for reporting.