Skip to content

Commit e0663b2

Browse files
authored
Merge pull request #390 from bearsunday/apcu
Fix apuc stub issue in web context
2 parents 8af8d3a + 567816d commit e0663b2

File tree

7 files changed

+11
-9
lines changed

7 files changed

+11
-9
lines changed

src-files/apcu.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ function apcu_sma_info($limited = false)
3636

3737
function apcu_store($key, $var, $ttl = 0)
3838
{
39+
return [];
3940
}
4041

4142
function apcu_fetch($key, &$success = null)

src/Compiler/CompileClassMetaInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class CompileClassMetaInfo
2121
*
2222
* @param class-string<T> $className
2323
*
24-
* @template T
24+
* @template T of object
2525
*/
2626
public function __invoke(Reader $reader, NamedParameterInterface $namedParams, string $className): void
2727
{

src/Compiler/CompileDependencies.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function __invoke(AbstractModule $module): AbstractModule
3131
foreach ($dependencies as $dependencyIndex) {
3232
$pos = strpos((string) $dependencyIndex, '-');
3333
assert(is_int($pos));
34+
/** @var ''|class-string $interface */
3435
$interface = substr((string) $dependencyIndex, 0, $pos);
3536
$name = substr((string) $dependencyIndex, $pos + 1);
3637
($this->newInstance)($interface, $name);

src/Compiler/FakeRun.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
use function assert;
2020
use function class_exists;
21-
use function is_object;
2221
use function ob_end_clean;
2322
use function ob_start;
2423
use function property_exists;
@@ -57,11 +56,9 @@ public function __invoke(): void
5756
($bootstrap)($this->appMeta->name, $this->context, $GLOBALS, $_SERVER); // 200 OK
5857
$_SERVER['REQUEST_METHOD'] = 'DELETE';
5958
$app = $this->injector->getInstance(AppInterface::class);
60-
assert(is_object($app));
6159
assert(property_exists($app, 'resource'));
6260
assert(property_exists($app, 'responder'));
6361
$ro = $this->injector->getInstance(NullPage::class);
64-
assert($ro instanceof NullPage);
6562
$ro->uri = new Uri('app://self/');
6663
/** @var NullPage $ro */
6764
$ro = $app->resource->get->object($ro)(['required' => 'string']);

src/Compiler/NewInstance.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public function __construct(InjectorInterface $injector)
3232
$this->injector = $injector;
3333
}
3434

35+
/**
36+
* @param ''|class-string $interface
37+
*/
3538
public function __invoke(string $interface, string $name = ''): void
3639
{
3740
$dependencyIndex = $interface . '-' . $name;

tests/Fake/fake-app/src/Module/App.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class App extends AbstractApp
1717
{
18-
public static $counfOfNew = 0;
18+
public static $countOfNewInstance = 0;
1919

2020
public $throwableHandler;
2121

@@ -31,6 +31,6 @@ public function setThrowableHandler(ThrowableHandlerInterface $handler)
3131
public function __construct(HttpCacheInterface $httpCache, RouterInterface $router, TransferInterface $responder, ResourceInterface $resource, ErrorInterface $error)
3232
{
3333
parent::__construct($httpCache, $router, $responder, $resource, $error);
34-
self::$counfOfNew++;
34+
self::$countOfNewInstance++;
3535
}
3636
}

tests/InjectorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ public function testCachedGetInstance(string $context, int $countOfNew): void
6666
$appDir = __DIR__ . '/Fake/fake-app';
6767
$exitCode = $this->runOnce($context);
6868
$this->assertSame(0, $exitCode);
69-
App::$counfOfNew = 0;
69+
App::$countOfNewInstance = 0;
7070
$injector = Injector::getInstance('FakeVendor\HelloWorld', $context, $appDir);
7171
$app = $injector->getInstance(AppInterface::class);
7272
assert($app instanceof AppInterface);
7373
$this->assertInstanceOf(AppInterface::class, $app);
74-
$this->assertSame($countOfNew, App::$counfOfNew);
74+
$count = App::$countOfNewInstance;
7575
// 2nd injector; AppInterface object should be stored as a singleton.
7676
$injector = Injector::getInstance('FakeVendor\HelloWorld', $context, $appDir);
7777
$app = $injector->getInstance(AppInterface::class);
7878
assert($app instanceof AppInterface);
7979
$this->assertInstanceOf(AppInterface::class, $app);
80-
$this->assertSame($countOfNew, App::$counfOfNew);
80+
$this->assertSame($count, App::$countOfNewInstance);
8181
}
8282

8383
/**

0 commit comments

Comments
 (0)