Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 29bc90d

Browse files
gappleGeoff Appleby
authored and
Geoff Appleby
committed
[ClassLoader] Use symfony/polyfill-apcu
1 parent 9d18913 commit 29bc90d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class ApcUniversalClassLoader extends UniversalClassLoader
7171
*/
7272
public function __construct($prefix)
7373
{
74-
if (!extension_loaded('apc')) {
74+
if (!function_exists('apcu_fetch')) {
7575
throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.');
7676
}
7777

@@ -87,8 +87,8 @@ public function __construct($prefix)
8787
*/
8888
public function findFile($class)
8989
{
90-
if (false === $file = apc_fetch($this->prefix.$class)) {
91-
apc_store($this->prefix.$class, $file = parent::findFile($class));
90+
if (false === $file = apcu_fetch($this->prefix.$class)) {
91+
apcu_store($this->prefix.$class, $file = parent::findFile($class));
9292
}
9393

9494
return $file;

src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
1515

1616
/**
17-
* @requires extension apc
17+
*
1818
*/
1919
class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
2020
{
2121
protected function setUp()
2222
{
2323
if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
24-
apc_clear_cache('user');
24+
apcu_clear_cache();
2525
} else {
2626
$this->markTestSkipped('APC is not enabled.');
2727
}
@@ -30,7 +30,7 @@ protected function setUp()
3030
protected function tearDown()
3131
{
3232
if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
33-
apc_clear_cache('user');
33+
apcu_clear_cache();
3434
}
3535
}
3636

@@ -39,7 +39,7 @@ public function testConstructor()
3939
$loader = new ApcUniversalClassLoader('test.prefix.');
4040
$loader->registerNamespace('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
4141

42-
$this->assertEquals($loader->findFile('\Apc\Namespaced\FooBar'), apc_fetch('test.prefix.\Apc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument');
42+
$this->assertEquals($loader->findFile('\Apc\Namespaced\FooBar'), apcu_fetch('test.prefix.\Apc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument');
4343
}
4444

4545
/**

0 commit comments

Comments
 (0)