4 Commits
1.2.0 ... 1.1.x

Author SHA1 Message Date
Grégoire Paris
1b33070b49 Merge pull request #33 from DieterHolvoet/issue-32
Fix Trying to access array offset on value of type null
2020-04-26 13:02:52 +02:00
Dieter Holvoet
41a2f0f445 Add type check to prevent PHP 7.4 warnings
PHP 7.4 introduces a "Trying to access array offset on value of type ..." warning for accessing null/bool/int/float/resource (everything but array, string and object) as if it were an array. This commit fixes an instance where this warning is emitted.

Fixes #32.
2020-04-26 12:57:05 +02:00
Grégoire Paris
d11bac73db Merge pull request #40 from pgrimaud/master
Fix typo in lib/Doctrine/Common/Reflection/TypedNoDefaultReflectionProperty.php
2020-04-18 23:41:10 +02:00
Pierre Grimaud
1c7272c98a Fix typos 2020-04-18 23:34:26 +02:00
4 changed files with 43 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ use const T_VAR;
use const T_VARIABLE;
use function array_merge;
use function file_get_contents;
use function is_array;
use function ltrim;
use function preg_match;
use function sprintf;
@@ -189,6 +190,9 @@ class StaticReflectionParser implements ReflectionProviderInterface
while (($token = $tokenParser->next()) && $token[0] !== T_STRING) {
continue;
}
if ($token === null) {
break;
}
$methodName = $token[1];
$this->docComment['method'][$methodName] = $docComment;
$docComment = '';
@@ -222,7 +226,7 @@ class StaticReflectionParser implements ReflectionProviderInterface
break;
}
$last_token = $token[0];
$last_token = is_array($token) ? $token[0] : false;
}
}

View File

@@ -13,7 +13,7 @@ class TypedNoDefaultReflectionProperty extends ReflectionProperty
* {@inheritDoc}
*
* Checks that a typed property is initialized before accessing its value.
* This is neccessary to avoid PHP error "Error: Typed property must not be accessed before initialization".
* This is necessary to avoid PHP error "Error: Typed property must not be accessed before initialization".
* Should be used only for reflecting typed properties without a default value.
*/
public function getValue($object = null)

View File

@@ -0,0 +1,13 @@
<?php
namespace Doctrine\Tests_PHP74\Common\Reflection\Dummies;
trait TokenParserAnonymousFunctionTestClass
{
protected function method()
{
return static function ($value) {
return $value;
};
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Doctrine\Tests_PHP74\Common\Reflection;
use Doctrine\Common\Reflection\Psr0FindFile;
use Doctrine\Common\Reflection\StaticReflectionParser;
use Doctrine\Tests_PHP74\Common\Reflection\Dummies\TokenParserAnonymousFunctionTestClass;
use PHPUnit\Framework\TestCase;
use function strlen;
use function substr;
class TokenParserAnonymousFunctionTest extends TestCase
{
public function testGetValue() : void
{
$testsRoot = substr(__DIR__, 0, -strlen(__NAMESPACE__) - 1);
$paths = [
'Doctrine\\Tests_PHP74' => [$testsRoot],
];
$staticReflectionParser = new StaticReflectionParser(TokenParserAnonymousFunctionTestClass::class, new Psr0FindFile($paths));
self::assertEquals('', $staticReflectionParser->getDocComment());
}
}