-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic support for tab indentation
Add a new "indent" option for the pretty printer, which can be use to control the indentation width, or switch it to use tabs. Tab width is currenlty hardcoded to 4, but also shouldn't matter much. Possibly the formatting-preserving printer should auto-detect the indentation in the future.
- Loading branch information
Showing
6 changed files
with
176 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Indentation | ||
----- | ||
<?php | ||
$x; | ||
----- | ||
$stmts[0] = new Stmt\If_(new Expr\Variable('a'), ['stmts' => $stmts]); | ||
----- | ||
!!indent=" " | ||
<?php | ||
if ($a) { | ||
$x; | ||
} | ||
----- | ||
<?php | ||
$x; | ||
----- | ||
$stmts[0] = new Stmt\If_(new Expr\Variable('a'), ['stmts' => $stmts]); | ||
----- | ||
!!indent="\t" | ||
<?php | ||
if ($a) { | ||
@@{"\t"}@@$x; | ||
} | ||
----- | ||
<?php | ||
if ($a) { | ||
@@{"\t"}@@$x; | ||
} | ||
----- | ||
$stmts[0]->stmts[] = new Stmt\Expression(new Expr\Variable('y')); | ||
----- | ||
!!indent="\t" | ||
<?php | ||
if ($a) { | ||
@@{"\t"}@@$x; | ||
@@{"\t"}@@$y; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
Indentation | ||
----- | ||
<?php | ||
|
||
class Test { | ||
/** | ||
* Comment | ||
*/ | ||
public function foo() { | ||
if (1) { | ||
echo $bar; | ||
} | ||
} | ||
} | ||
----- | ||
!!indent=" " | ||
class Test | ||
{ | ||
/** | ||
* Comment | ||
*/ | ||
public function foo() | ||
{ | ||
if (1) { | ||
echo $bar; | ||
} | ||
} | ||
} | ||
----- | ||
<?php | ||
|
||
class Test { | ||
/** | ||
* Comment | ||
*/ | ||
public function foo() { | ||
if (1) { | ||
echo $bar; | ||
} | ||
} | ||
} | ||
----- | ||
!!indent=" " | ||
class Test | ||
{ | ||
/** | ||
* Comment | ||
*/ | ||
public function foo() | ||
{ | ||
if (1) { | ||
echo $bar; | ||
} | ||
} | ||
} | ||
----- | ||
<?php | ||
|
||
class Test { | ||
/** | ||
* Comment | ||
*/ | ||
public function foo() { | ||
if (1) { | ||
echo $bar; | ||
} | ||
} | ||
} | ||
----- | ||
!!indent="\t" | ||
class Test | ||
{ | ||
@@{"\t"}@@/** | ||
@@{"\t"}@@ * Comment | ||
@@{"\t"}@@ */ | ||
@@{"\t"}@@public function foo() | ||
@@{"\t"}@@{ | ||
@@{"\t\t"}@@if (1) { | ||
@@{"\t\t\t"}@@echo $bar; | ||
@@{"\t\t"}@@} | ||
@@{"\t"}@@} | ||
} |