forked from humbug/php-scoper
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes humbug#965.
- Loading branch information
Showing
10 changed files
with
135 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use Set040\Php20; | ||
|
||
if (PHP_VERSION_ID >= 200_000) { | ||
return; | ||
} | ||
|
||
if (!defined('NEW_PHP20_CONSTANT')) { | ||
define('NEW_PHP20_CONSTANT', 42); | ||
} | ||
|
||
if (!function_exists('new_php20_function')) { | ||
function new_php20_function(bool $echo = false): void { Php20::new_php20_function($echo); } | ||
} |
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,11 @@ | ||
{ | ||
"bin": "index.php", | ||
"autoload": { | ||
"files": ["bootstrap.php"], | ||
"classmap": ["stubs"], | ||
"psr-4": { | ||
"Set040\\Polyfill\\": "src/", | ||
"Set040\\": "src/" | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
OK. |
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,27 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace App; | ||
|
||
use NewPhp20Interface; | ||
use NewPhp20Class; | ||
use function new_php20_function; | ||
use const NEW_PHP20_CONSTANT; | ||
use const PHP_EOL; | ||
|
||
require file_exists(__DIR__.'/vendor/scoper-autoload.php') | ||
? __DIR__.'/vendor/scoper-autoload.php' | ||
: __DIR__.'/vendor/autoload.php'; | ||
|
||
// This file mimics the execution of an app relying on a polyfill. | ||
// | ||
// From PHP-Scoper point of view, marking a symbol as excluded is | ||
// akin to say this is a PHP native symbol. | ||
|
||
// Consume the polyfilled code. | ||
|
||
class NewPhp20Child implements NewPhp20Interface {} | ||
new NewPhp20Class(); | ||
new_php20_function(); | ||
$x = NEW_PHP20_CONSTANT; | ||
|
||
echo "OK.".PHP_EOL; |
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,14 @@ | ||
<?php declare(strict_types=1); | ||
|
||
return [ | ||
'exclude-classes' => [ | ||
'NewPhp20Interface', | ||
'NewPhp20Class', | ||
], | ||
'exclude-functions' => [ | ||
'new_php20_function', | ||
], | ||
'exclude-constants' => [ | ||
'NEW_PHP20_CONSTANT', | ||
], | ||
]; |
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 declare(strict_types=1); | ||
|
||
namespace Set040; | ||
|
||
final class Php20 | ||
{ | ||
public static function new_php20_function(bool $echo = false): void | ||
{ | ||
if ($echo) { | ||
echo "Called `new_php20_function()`."; | ||
} | ||
} | ||
|
||
private function __construct() | ||
{ | ||
} | ||
} |
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,7 @@ | ||
<?php declare(strict_types=1); | ||
|
||
if (PHP_VERSION_ID < 200_000) { | ||
final class NewPhp20Class | ||
{ | ||
} | ||
} |
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,7 @@ | ||
<?php declare(strict_types=1); | ||
|
||
if (PHP_VERSION_ID < 200_000) { | ||
interface NewPhp20Interface | ||
{ | ||
} | ||
} |