Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/ObjectManagement/ObjectManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public function getObjectNameByClassName($className): string|false
* Returns the implementation class name for the specified object
*
* @param string $objectName The object name
* @return string|false The class name corresponding to the given object name or false if no such object is registered
* @return class-string|false The class name corresponding to the given object name or false if no such object is registered
* @api
*/
public function getClassNameByObjectName($objectName): string|false
Expand Down
4 changes: 2 additions & 2 deletions Neos.Flow/Classes/ObjectManagement/ObjectManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function getObjectNameByClassName($className);
* Returns the implementation class name for the specified object
*
* @param string $objectName The object name
* @return string The class name corresponding to the given object name or false if no such object is registered
* @return class-string|false The class name corresponding to the given object name or false if no such object is registered
* @api
*/
public function getClassNameByObjectName($objectName);
Expand All @@ -119,7 +119,7 @@ public function getClassNameByObjectName($objectName);
* Returns the key of the package the specified object is contained in.
*
* @param string $objectName The object name
* @return string The package key or false if no such object exists
* @return string|false The package key or false if no such object exists
*/
public function getPackageKeyByObjectName($objectName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public function getMethodAnnotation(ReflectionMethod $method, $annotationName)
* Gets the annotations applied to a property.
*
* @param ReflectionProperty $property The ReflectionProperty of the property from which the annotations should be read.
* @return array<object> An array of Annotations.
* @return array<int,array<object>> An array of Annotations.
* @phpstan-ignore method.childReturnType
*/
public function getPropertyAnnotations(ReflectionProperty $property)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function getTargetPropertyName($sourcePropertyName)

/**
* @param string $typeConverterClassName
* @param string $key
* @param string|int $key
* @return mixed configuration value for the specific $typeConverterClassName. Can be used by Type Converters to fetch converter-specific configuration.
* @api
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getTargetPropertyName($sourcePropertyName);

/**
* @param string $typeConverterClassName
* @param string $key
* @param string|int $key
* @return mixed configuration value for the specific $typeConverterClassName. Can be used by Type Converters to fetch converter-specific configuration
* @api
*/
Expand Down
24 changes: 15 additions & 9 deletions Neos.Flow/Classes/Reflection/ClassReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/**
* Extended version of the ReflectionClass
*
* @extends \ReflectionClass<object>
* @Flow\Proxy(false)
*/
class ClassReflection extends \ReflectionClass
Expand All @@ -39,7 +40,7 @@ static function ($className) use ($classNameOrObject) {
}

/**
* @var DocCommentParser Holds an instance of the doc comment parser for this class
* @var ?DocCommentParser Holds an instance of the doc comment parser for this class
*/
protected $docCommentParser;

Expand All @@ -48,12 +49,14 @@ static function ($className) use ($classNameOrObject) {
* that MethodReflection objects are returned instead of the
* original ReflectionMethod instances.
*
* @return MethodReflection Method reflection object of the constructor method
* @return ?MethodReflection Method reflection object of the constructor method
*/
public function getConstructor(): MethodReflection
public function getConstructor(): ?MethodReflection
{
$parentConstructor = parent::getConstructor();
return (!is_object($parentConstructor)) ? $parentConstructor : new MethodReflection($this->getName(), $parentConstructor->getName());
return $parentConstructor === null
? $parentConstructor
: new MethodReflection($this->getName(), $parentConstructor->getName());
}

/**
Expand Down Expand Up @@ -165,7 +168,7 @@ public function isTaggedWith($tag)
/**
* Returns an array of tags and their values
*
* @return array Tags and values
* @return array<string,array<int,string>> Tags and values
*/
public function getTagsValues()
{
Expand All @@ -175,7 +178,7 @@ public function getTagsValues()
/**
* Returns the values of the specified tag
* @param string $tag
* @return array Values of the given tag
* @return array<int,string> Values of the given tag
*/
public function getTagValues($tag)
{
Expand Down Expand Up @@ -205,7 +208,7 @@ public function newInstanceWithoutConstructor(): object
{
$instance = parent::newInstanceWithoutConstructor();

if (method_exists($instance, '__wakeup') && is_callable([$instance, '__wakeup'])) {
if (method_exists($instance, '__wakeup')) {
$instance->__wakeup();
}

Expand All @@ -221,8 +224,11 @@ public function newInstanceWithoutConstructor(): object
protected function getDocCommentParser()
{
if (!is_object($this->docCommentParser)) {
$this->docCommentParser = new DocCommentParser;
$this->docCommentParser->parseDocComment($this->getDocComment());
$this->docCommentParser = new DocCommentParser();
$docComment = $this->getDocComment();
if ($docComment) {
$this->docCommentParser->parseDocComment($docComment);
}
}
return $this->docCommentParser;
}
Expand Down
32 changes: 25 additions & 7 deletions Neos.Flow/Classes/Reflection/ClassSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,20 @@ class ClassSchema
/**
* Properties of the class which need to be persisted
*
* @var array
* @var array<string,array{
* type: string,
* elementType: ?string,
* nullable: bool,
* lazy: bool,
* transient: bool,
* }>
*/
protected $properties = [];

/**
* The properties forming the identity of an object
*
* @var array
* @var array<string,string>
*/
protected $identityProperties = [];

Expand Down Expand Up @@ -137,7 +143,13 @@ public function addProperty($name, $type, $lazy = false, $transient = false)
* hasProperty($propertyName) before!
*
* @param string $propertyName
* @return array
* @return array{
* type: string,
* elementType: ?string,
* nullable: bool,
* lazy: bool,
* transient: bool,
* }
*/
public function getProperty($propertyName)
{
Expand All @@ -147,7 +159,13 @@ public function getProperty($propertyName)
/**
* Returns all properties defined in this schema
*
* @return array
* @return array<string,array{
* type: string,
* elementType: ?string,
* nullable: bool,
* lazy: bool,
* transient: bool,
* }>
*/
public function getProperties()
{
Expand Down Expand Up @@ -198,7 +216,7 @@ public function getModelType()
/**
* Set the class name of the repository managing an entity.
*
* @param string $repositoryClassName
* @param ?string $repositoryClassName
* @return void
* @throws Exception\ClassSchemaConstraintViolationException
*/
Expand All @@ -211,7 +229,7 @@ public function setRepositoryClassName($repositoryClassName)
}

/**
* @return string
* @return ?string
*/
public function getRepositoryClassName()
{
Expand Down Expand Up @@ -300,7 +318,7 @@ public function markAsIdentityProperty($propertyName)
/**
* Gets the properties (names and types) forming the identity of an object.
*
* @return array
* @return array<string,string>
* @see markAsIdentityProperty()
*/
public function getIdentityProperties()
Expand Down
12 changes: 6 additions & 6 deletions Neos.Flow/Classes/Reflection/DocCommentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DocCommentParser

/**
* An array of tag names and their values (multiple values are possible)
* @var array
* @var array<string,array<int,string>>
*/
protected $tags = [];

Expand All @@ -47,9 +47,9 @@ public function parseDocComment($docComment)

$lines = explode(chr(10), $docComment);
foreach ($lines as $line) {
$line = trim(preg_replace('/\*\/$/', '', $line));
$line = trim(preg_replace('/\*\/$/', '', $line) ?: '');
if ($line !== '' && strpos($line, '* @') !== false) {
$this->parseTag(substr($line, strpos($line, '@')));
$this->parseTag(substr($line, strpos($line, '@') ?: 0));
} elseif (count($this->tags) === 0) {
$this->description .= preg_replace('/\s*\\/?[\\\\*]*\s?(.*)$/', '$1', $line) . chr(10);
}
Expand All @@ -60,7 +60,7 @@ public function parseDocComment($docComment)
/**
* Returns the tags which have been previously parsed
*
* @return array Array of tag names and their (multiple) values
* @return array<string,array<int,string>> Array of tag names and their (multiple) values
*/
public function getTagsValues()
{
Expand All @@ -73,7 +73,7 @@ public function getTagsValues()
* available.
*
* @param string $tagName The tag name to retrieve the values for
* @return array The tag's values
* @return array<int,string> The tag's values
* @throws Exception
*/
public function getTagValues($tagName)
Expand Down Expand Up @@ -116,7 +116,7 @@ protected function parseTag($line)
{
$tagAndValue = [];
if (preg_match('/@[A-Za-z0-9\\\\]+\\\\([A-Za-z0-9]+)(?:\\((.*)\\))?$/', $line, $tagAndValue) === 0) {
$tagAndValue = preg_split('/\s/', $line, 2);
$tagAndValue = preg_split('/\s/', $line, 2) ?: [];
} else {
array_shift($tagAndValue);
}
Expand Down
19 changes: 8 additions & 11 deletions Neos.Flow/Classes/Reflection/MethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class MethodReflection extends \ReflectionMethod
{
/**
* @var DocCommentParser An instance of the doc comment parser
* @var ?DocCommentParser An instance of the doc comment parser
*/
protected $docCommentParser;

Expand Down Expand Up @@ -66,7 +66,7 @@ public function isTaggedWith($tag)
/**
* Returns an array of tags and their values
*
* @return array Tags and values
* @return array<string,array<int,string>> Tags and values
*/
public function getTagsValues()
{
Expand All @@ -77,7 +77,7 @@ public function getTagsValues()
* Returns the values of the specified tag
*
* @param string $tag Tag name to check for
* @return array Values of the given tag
* @return array<int,string> Values of the given tag
*/
public function getTagValues($tag)
{
Expand All @@ -99,9 +99,6 @@ public function getDescription()
*/
public function getDeclaredReturnType()
{
if (!is_callable([$this, 'getReturnType'])) {
return null;
}
$type = $this->getReturnType();
return $type !== null ? ltrim((string)$type, '?') : null;
}
Expand All @@ -111,9 +108,6 @@ public function getDeclaredReturnType()
*/
public function isDeclaredReturnTypeNullable()
{
if (!is_callable([$this, 'getReturnType'])) {
return false;
}
$type = $this->getReturnType();
return $type !== null && $type->allowsNull();
}
Expand All @@ -127,8 +121,11 @@ public function isDeclaredReturnTypeNullable()
protected function getDocCommentParser()
{
if (!is_object($this->docCommentParser)) {
$this->docCommentParser = new DocCommentParser;
$this->docCommentParser->parseDocComment($this->getDocComment());
$this->docCommentParser = new DocCommentParser();
$docComment = $this->getDocComment();
if ($docComment) {
$this->docCommentParser->parseDocComment($docComment);
}
}
return $this->docCommentParser;
}
Expand Down
7 changes: 4 additions & 3 deletions Neos.Flow/Classes/Reflection/ParameterReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ class ParameterReflection extends \ReflectionParameter
/**
* Returns the declaring class
*
* @return ClassReflection The declaring class
* @return ?ClassReflection The declaring class
*/
public function getDeclaringClass(): ClassReflection
public function getDeclaringClass(): ?ClassReflection
{
return new ClassReflection(parent::getDeclaringClass()->getName());
$reflectionClass = parent::getDeclaringClass();
return $reflectionClass ? new ClassReflection($reflectionClass->getName()) : null;
}

/**
Expand Down
13 changes: 8 additions & 5 deletions Neos.Flow/Classes/Reflection/PropertyReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class PropertyReflection extends \ReflectionProperty
{
/**
* @var DocCommentParser An instance of the doc comment parser
* @var ?DocCommentParser An instance of the doc comment parser
*/
protected $docCommentParser;

Expand Down Expand Up @@ -58,7 +58,7 @@ public function getDeclaringClass(): ClassReflection
/**
* Returns an array of tags and their values
*
* @return array Tags and values
* @return array<string,array<int,string>> Tags and values
*/
public function getTagsValues()
{
Expand All @@ -69,7 +69,7 @@ public function getTagsValues()
* Returns the values of the specified tag
*
* @param string $tag
* @return array Values of the given tag
* @return array<int,string> Values of the given tag
*/
public function getTagValues($tag)
{
Expand Down Expand Up @@ -137,8 +137,11 @@ public function setValue($object = null, $value = null): void
protected function getDocCommentParser()
{
if (!is_object($this->docCommentParser)) {
$this->docCommentParser = new DocCommentParser;
$this->docCommentParser->parseDocComment($this->getDocComment());
$this->docCommentParser = new DocCommentParser();
$docComment = $this->getDocComment();
if ($docComment) {
$this->docCommentParser->parseDocComment($docComment);
}
}
return $this->docCommentParser;
}
Expand Down
Loading