PhpStorm 2024.3 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 arrows

Display code folding icons in the editor.

From the list, select the way in which the icons for unfolded areas should be displayed:

  • Always: code folding icons are always displayed in the gutter.

  • On mouse hover: code folding icons appear only when you hover over the gutter.

Code folding

Show bottom arrows: display the bottom folding arrows in the gutter as well. Otherwise, only the top arrows are shown.

Fold by default

Select the code fragments that 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

Option

Unfolded code

Folded code

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

Folds regions that are marked with editor-fold or region comments.

For more information, refer to Custom folding regions.

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

JavaScript

Option

Unfolded code

Folded code

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

Option

Unfolded code

Folded code

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;

Attribute

use JetBrains\PhpStorm\Internal\LanguageLevelTypeAware; #[LanguageLevelTypeAware( ['8.0' => 'int|false'], default: 'int|false|null' ) ] function foo() { }
use JetBrains\PhpStorm\Internal\LanguageLevelTypeAware; #[LanguageLevelTypeAware(...)] function foo() { }

Attribute list

use JetBrains\PhpStorm\ExpectedValues; use JetBrains\PhpStorm\Deprecated; #[ ExpectedValues, Deprecated ] function foo() { }
use JetBrains\PhpStorm\ExpectedValues; use JetBrains\PhpStorm\Deprecated; #[...] function foo() { }

SQL

Option

Unfolded code

Folded code

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

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

XML

Option

Unfolded code

Folded code

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: 17 October 2024