-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bug #2732 : PSR12.Files.FileHeader misidentifies file header in…
… mixed content file This required a rewrite of the sniff to process the entire file looking for a file header. It's still impossible to determine if a docblock is a file comment or not, but it should work with more code now.
- Loading branch information
Showing
10 changed files
with
221 additions
and
43 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
5 changes: 5 additions & 0 deletions
5
src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.10.inc.fixed
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,5 @@ | ||
<?php | ||
|
||
// Do nothing | ||
// Do nothing | ||
// Do nothing |
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,21 @@ | ||
<?php | ||
/** | ||
* Template file docblock. | ||
* | ||
* @package Vendor\Package | ||
*/ | ||
|
||
if (!defined('ABSPATH')) { | ||
exit; | ||
} | ||
|
||
?> | ||
|
||
<p><?php echo 'Some text string'; ?></p> | ||
|
||
<?php | ||
|
||
/** | ||
* Docblock. | ||
*/ | ||
include 'foo.php'; |
22 changes: 22 additions & 0 deletions
22
src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.11.inc.fixed
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,22 @@ | ||
<?php | ||
|
||
/** | ||
* Template file docblock. | ||
* | ||
* @package Vendor\Package | ||
*/ | ||
|
||
if (!defined('ABSPATH')) { | ||
exit; | ||
} | ||
|
||
?> | ||
|
||
<p><?php echo 'Some text string'; ?></p> | ||
|
||
<?php | ||
|
||
/** | ||
* Docblock. | ||
*/ | ||
include 'foo.php'; |
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,17 @@ | ||
<?php | ||
echo 'Some content'; | ||
?> | ||
<?php | ||
/** | ||
* The header is not the first thing in the file. | ||
*/ | ||
|
||
namespace Vendor\Package; | ||
|
||
/** | ||
* FooBar is an example class. | ||
*/ | ||
class FooBar | ||
{ | ||
// ... additional PHP code ... | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.12.inc.fixed
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,18 @@ | ||
<?php | ||
echo 'Some content'; | ||
?> | ||
<?php | ||
|
||
/** | ||
* The header is not the first thing in the file. | ||
*/ | ||
|
||
namespace Vendor\Package; | ||
|
||
/** | ||
* FooBar is an example class. | ||
*/ | ||
class FooBar | ||
{ | ||
// ... additional PHP code ... | ||
} |
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,24 @@ | ||
<?php | ||
|
||
/** | ||
* File docblock. | ||
* | ||
* @package Vendor\Package | ||
*/ | ||
|
||
class Foo { | ||
/** | ||
* Function docblock. | ||
*/ | ||
public function bar() { | ||
do_something(); | ||
?> | ||
<p>Demo</p> | ||
|
||
<?php | ||
/** | ||
* Arbitrary docblock. | ||
*/ | ||
api_call(); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.7.inc.fixed
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,3 @@ | ||
<?php | ||
|
||
// Do nothing |
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