PhpStorm 2022.1 Help

Code Folding

Use this page to specify the default code folding settings. For shortcuts on how to expand or collapse code elements, refer to the code folding section.

Item

Description

Show code folding outline

Select this checkbox if you want the code folding toggles to be shown in the editor. Clear the checkbox to hide the toggles.

Fold by default

Select the code fragments which should be folded by default, that is, when a file is first opened in the editor.

Fold by Default section

In this section, choose the language-specific elements that should be folded by default when you open a file of the corresponding type.

General

Original

Folded

File header

Applies to Header comment blocks.

<?php /** * Start the application * * This function processes the request and * sends the response back to the browser. */ function start(){ };
<?php /*** Start the application ...*/ function start(){ };

Imports

Applies in non-PHP contexts such as JavaScript.

import defaultExport from "module-name"; import * as name from "module-name"; import { foo , bar } from "specific/file"; import "module-name"; var promise = import("module-name");
import ... var promise = import("module-name");

Documentation comments

/** * User constructor. * @param $name * @param $age */ function __construct($name, $age) { $this->_age = $age; $this->_name = $name; }
/** User constructor. ...*/ function __construct($name, $age) { $this->_age = $age; $this->_name = $name; }

Method bodies

Applies in non-PHP contexts such as JavaScript.

class User { constructor(name) { this.name = name; } get name() { return this._name; } set name(value) { this._name = value; } }
class User { constructor(name) {...} get name() {...} set name(value) {...} }

Custom folding regions

See Use the Surround With action for details.

//<editor-fold desc="Folding region"> function foo() { bar(); } foo(); //</editor-fold>
Folding region

JavaScript

Original

Folded

One-line functions in JavaScript and TypeScript

var obj = { id: 1, timer: function timer() { setTimeOut(() => { console.log(this); console.log(this.id); }, 1000); } };
var obj = { id: 1, timer: function timer() { setTimeOut(() => {...}, 1000); } };

Object literals

var myObject = { a: 'value', b: 2, c: false };
var myObject = {a: 'value'...};

Array literals

var myArray = [ 'foo', 'bar', 'baz' ];
var myArray = [...];

XML literals

var html = <html> <p id="p1">First paragraph</p> <p id="p2">Second paragraph</p> </html>;
var html = <html...>;

PHP

Original

Folded

Class body

class Foo { public function bar() { } }
class Foo {...}

Imports

use App\User; use App\Controllers\Controller; class MyClass() { }
use ... class MyClass() { }

Method body

class Foo { public function bar() { echo 'baz'; } }
class Foo { public function bar() {...} }

Function body

<?php function foo($bar) { echo $bar; }
<?php function foo($bar) {...}

Tags

<html> <body> <?php echo '<p> PHP output </p>'; ?> </body> </html>
<html> <body> <?php...?> </body> </html>

HEREDOC/NOWDOC

<?php echo <<<'Label' Example of a nowdoc string. Label;
<?php echo <<<'Label'...Label;

SQL

Original

Folded

Put underscores inside numeric literals (6-digit or longer)

DECLARE @i BIGINT = 1000000000;
DECLARE @i BIGINT = 1_000_000_000;

XML

Original

Folded

XML Tags

<?xml version="1.0" encoding="UTF-8"?> <phpunit> <testsuite name="MyTestSuite"> <directory>tests</directory> </testsuite> </phpunit>
<?xml version="1.0" encoding="UTF-8"?> <phpunit...>

HTML 'style' attribute

<html> <body> <h1 style="color:blue;"> Heading </h1> <p style="color:red;"> Paragraph </p> </body> </html>
<html> <body> <h1 style="..."> Heading </h1> <p style="..."> Paragraph </p> </body> </html>

XML entities

<!DOCTYPE html> <html> <body> <p> Enclose a tag in < and > </p> </body> </html>
<!DOCTYPE html> <html> <body> <p> Enclose a tag in < and > </p> </body> </html>

Data URIs

<img src="data:image/png; base64, 2P4//8/w38gljNBAAO9TXL0Y4O"/>
<img src="data:"/>
Last modified: 21 September 2021