Skip to content

Commit

Permalink
Fix wrong phpdoc typehints based off PHPStan level 5 suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenRtbg authored and cweiske committed Mar 17, 2024
1 parent 49f1fb2 commit 0b5b559
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/JsonMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class JsonMapper
* PSR-3 compatible logger object
*
* @link http://www.php-fig.org/psr/psr-3/
* @var object
* @var \Psr\Log\LoggerInterface|null
* @see setLogger()
*/
protected $logger;
Expand Down Expand Up @@ -142,7 +142,12 @@ class JsonMapper
* @param object|class-string $object Object to map $json data into
*
* @return mixed Mapped object is returned.
* @see mapArray()
*
* @template T
* @phpstan-param class-string<T>|T $object
* @phpstan-return T
*
* @see mapArray()
*/
public function map($json, $object)
{
Expand Down Expand Up @@ -355,10 +360,10 @@ public function map($json, $object)
/**
* Convert a type name to a fully namespaced type name.
*
* @param string $type Type name (simple type or class name)
* @param string $strNs Base namespace that gets prepended to the type name
* @param string|null $type Type name (simple type or class name)
* @param string $strNs Base namespace that gets prepended to the type name
*
* @return string Fully-qualified type name with namespace
* @return string|null Fully-qualified type name with namespace
*/
protected function getFullNamespace($type, $strNs)
{
Expand All @@ -377,8 +382,8 @@ protected function getFullNamespace($type, $strNs)
/**
* Check required properties exist in json
*
* @param array $providedProperties array with json properties
* @param object $rc Reflection class to check
* @param array $providedProperties array with json properties
* @param ReflectionClass $rc Reflection class to check
*
* @throws JsonMapper_Exception
*
Expand Down Expand Up @@ -720,10 +725,10 @@ protected function createInstance(
* Get the mapped class/type name for this class.
* Returns the incoming classname if not mapped.
*
* @param string $type Type name to map
* @param mixed $jvalue Constructor parameter (the json value)
* @param string|null $type Type name to map
* @param mixed $jvalue Constructor parameter (the json value)
*
* @return string The mapped type/class name
* @return string|null The mapped type/class name
*/
protected function getMappedType($type, $jvalue = null)
{
Expand Down Expand Up @@ -856,9 +861,9 @@ protected function isNullable($type)
/**
* Remove the 'null' section of a type
*
* @param string $type type name from the phpdoc param
* @param string|null $type type name from the phpdoc param
*
* @return string The new type value
* @return string|null The new type value
*/
protected function removeNullable($type)
{
Expand Down Expand Up @@ -931,7 +936,7 @@ protected static function parseAnnotations($docblock)
* @param string $message Text to log
* @param array $context Additional information
*
* @return null
* @return void
*/
protected function log($level, $message, array $context = array())
{
Expand All @@ -943,9 +948,9 @@ protected function log($level, $message, array $context = array())
/**
* Sets a logger instance on the object
*
* @param LoggerInterface $logger PSR-3 compatible logger object
* @param \Psr\Log\LoggerInterface $logger PSR-3 compatible logger object
*
* @return null
* @return void
*/
public function setLogger($logger)
{
Expand Down

0 comments on commit 0b5b559

Please sign in to comment.