-
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.
PEAR IncludingFileSniff no longer produces invalid code when removing…
… parenthesis from require/include statements
- Loading branch information
Showing
5 changed files
with
111 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,4 +95,5 @@ if ($var == false) { | |
|
||
} | ||
|
||
?> | ||
require_once ('blank.inc'); | ||
include_once ('blank.inc'); |
99 changes: 99 additions & 0 deletions
99
CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.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,99 @@ | ||
<?php | ||
|
||
// These are statements and should not have brackets. | ||
require_once 'blank.inc'; | ||
require 'blank.inc'; | ||
|
||
$test = true; | ||
|
||
// Conditionally including a class file: use include_once | ||
if ($test) { | ||
include_once 'blank.inc'; | ||
include 'blank.inc'; | ||
} | ||
|
||
// Unconditionally including a class file: use require_once | ||
require_once 'blank.inc'; | ||
require 'blank.inc'; | ||
|
||
|
||
// These are ok | ||
if ($test) { | ||
include_once 'blank.inc'; | ||
include 'blank.inc'; | ||
} | ||
|
||
require_once 'blank.inc'; | ||
require 'blank.inc'; | ||
|
||
?> | ||
<pre> | ||
Some content goes here. | ||
<?php | ||
require_once 'blank.inc'; | ||
require 'blank.inc'; | ||
require_once 'blank.inc'; | ||
require 'blank.inc'; | ||
?> | ||
</pre> | ||
<?php | ||
|
||
if (include_once 'blank.inc') { | ||
$var = include_once 'blank.inc'; | ||
if ($var === true) { | ||
} | ||
} | ||
|
||
if (include_once 'blank.inc') { | ||
$var = include_once 'blank.inc'; | ||
if ($var === true) { | ||
} | ||
} | ||
|
||
function get_some_value() | ||
{ | ||
include_once 'blank.inc'; | ||
include 'blank.inc'; | ||
|
||
// These are ok | ||
if ($test) { | ||
include_once 'blank.inc'; | ||
include 'blank.inc'; | ||
} | ||
|
||
include_once 'blank.inc'; | ||
include 'blank.inc'; | ||
|
||
?> | ||
<pre> | ||
Some content goes here. | ||
<?php | ||
include_once 'blank.inc'; | ||
include 'blank.inc'; | ||
include_once 'blank.inc'; | ||
include 'blank.inc'; | ||
?> | ||
</pre> | ||
<?php | ||
|
||
if (include_once 'blank.inc') { | ||
$var = include_once 'blank.inc'; | ||
if ($var === true) { | ||
} | ||
} | ||
|
||
if (include_once 'blank.inc') { | ||
$var = include_once 'blank.inc'; | ||
if ($var === true) { | ||
} | ||
} | ||
} | ||
|
||
|
||
$var = include_once 'blank.inc'; | ||
if ($var == false) { | ||
|
||
} | ||
|
||
require_once 'blank.inc'; | ||
require_once 'blank.inc'; |
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