Skip to content

Commit c5f9d24

Browse files
committed
Fix overriding Memcache::get() and MemcachePool::get()
1 parent fc7d7b4 commit c5f9d24

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

resources/functionMap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6412,7 +6412,7 @@
64126412
'Memcache::decrement' => ['int', 'key'=>'string', 'value='=>'int'],
64136413
'Memcache::delete' => ['bool', 'key'=>'string', 'timeout='=>'int'],
64146414
'Memcache::flush' => ['bool'],
6415-
'Memcache::get' => ['string|array|false', 'key'=>'string', 'flags='=>'array', 'keys='=>'array'],
6415+
'Memcache::get' => ['string|array|false', 'key'=>'string', '&flags='=>'array', '&keys='=>'array'],
64166416
'Memcache::getExtendedStats' => ['array', 'type='=>'string', 'slabid='=>'int', 'limit='=>'int'],
64176417
'Memcache::getServerStatus' => ['int', 'host'=>'string', 'port='=>'int'],
64186418
'Memcache::getStats' => ['array', 'type='=>'string', 'slabid='=>'int', 'limit='=>'int'],
@@ -6479,7 +6479,7 @@
64796479
'MemcachePool::decrement' => ['int', 'key'=>'string', 'value='=>'int'],
64806480
'MemcachePool::delete' => ['bool', 'key'=>'string', 'timeout='=>'int'],
64816481
'MemcachePool::flush' => ['bool'],
6482-
'MemcachePool::get' => ['string|array|false', 'key'=>'string', 'flags='=>'array', 'keys='=>'array'],
6482+
'MemcachePool::get' => ['string|array|false', 'key'=>'string', '&flags='=>'array', '&keys='=>'array'],
64836483
'MemcachePool::getExtendedStats' => ['array', 'type='=>'string', 'slabid='=>'int', 'limit='=>'int'],
64846484
'MemcachePool::getServerStatus' => ['int', 'host'=>'string', 'port='=>'int'],
64856485
'MemcachePool::getStats' => ['array', 'type='=>'string', 'slabid='=>'int', 'limit='=>'int'],

src/Reflection/SignatureMap/SignatureMapParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private function getParameterInfoFromName(string $parameterNameString): array
9797
}
9898
if (strpos($reference, '&rw') === 0) {
9999
$passedByReference = PassedByReference::createReadsArgument();
100-
} elseif (strpos($reference, '&w') === 0) {
100+
} elseif (strpos($reference, '&w') === 0 || strpos($reference, '&') === 0) {
101101
$passedByReference = PassedByReference::createCreatesNewVariable();
102102
} else {
103103
$passedByReference = PassedByReference::createNo();

tests/PHPStan/Rules/Methods/MethodSignatureRuleTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,15 @@ public function testBug4854(): void
351351
$this->analyse([__DIR__ . '/data/bug-4854.php'], []);
352352
}
353353

354+
public function testMemcachePoolGet(): void
355+
{
356+
if (!self::$useStaticReflectionProvider) {
357+
$this->markTestSkipped('Test requires static reflection.');
358+
}
359+
360+
$this->reportMaybes = true;
361+
$this->reportStatic = true;
362+
$this->analyse([__DIR__ . '/data/memcache-pool-get.php'], []);
363+
}
364+
354365
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace MemcachePoolGet;
4+
5+
class CacheShim extends \MemcachePool
6+
{
7+
8+
public function get($arg, &$flags = null, &$cas = null)
9+
{
10+
return false;
11+
}
12+
13+
}

0 commit comments

Comments
 (0)