1. Go to this page and download the library: Download plesk/php-scoper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
declare(strict_types=1);
// scoper.inc.php
return [
'whitelist' => [
'PHPUnit\Framework\TestCase',
'PHPUNIT_VERSION',
'iter\count',
'Acme\Foo*', // Warning: will not whitelist sub namespaces like Acme\Foo\Bar but will whitelist symbols like
// Acme\Foo or Acme\Fooo
],
];
namespace Acme;
class Foo {}
namespace Humbug\Acme;
class Foo {}
\class_alias('Humbug\\Acme\\Foo', 'Acme\\Foo', \false);
// scoper-autoload.php @generated by PhpScoper
$loader = g of
// `Humbug\Acme\Foo` after the
// Composer autoload is registered
return $loader;
namespace Acme;
const FOO = 'X';
namespace Humbug\Acme;
\define('FOO', 'X');
// No namespace: this is the global namespace
if (!function_exists('dd')) {
function dd() {}
}
namespace PhpScoperPrefix;
if (!function_exists('PhpScoperPrefix\dd')) {
function dd() {...}
}
// scoper-autoload.php @generated by PhpScoper
$loader = n \PhpScoperPrefix\dd(...func_get_args());
}
}
return $loader;
declare(strict_types=1);
// scoper.inc.php
return [
'whitelist' => [
'PHPUnit\F*', // Will only whitelist symbols such as PHPUnit\F or PHPunit\Foo, but not symbols belonging to
// sub-namespaces like PHPunit\Foo\Bar
],
];
const ISO8601_BASIC = 'Ymd\THis\Z';
<<<PHP_HEREDOC
use Acme\Foo;
PHP_HEREDOC;
<<<EOF
{$namespaceLine}
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
if (\\class_exists(\\Container{$hash}\\{$options['class']}::class, false)) {
// no-op
} elseif (!tainer{$hash}\\{$options['class']}(array(
'container.build_hash' => '$hash',
'container.build_id' => '$id',
'container.build_time' => $time,
), __DIR__.\\DIRECTORY_SEPARATOR.'Container{$hash}');
EOF;
['Acme\Foo', 'bar'];
'Acme\Foo::bar';
class_exists('Acme\Foo');
// Will be prefixed into:
\class_exists('Humbug\Acme\Foo');
namespace Foo;
is_array([]);
namespace Foo;
use function Foo\is_array;
is_array([]);