Skip to content

Commit

Permalink
Merge pull request #415 from edudobay/php81_return_types
Browse files Browse the repository at this point in the history
Use return types from JsonSerializable/IteratorAggregate (fixes PHP 8.1 deprecations)
  • Loading branch information
veewee authored Jan 27, 2022
2 parents 159d890 + f53c9b2 commit e47ea71
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ private function implementGetIterator(ClassGenerator $class, Property $firstProp
'return new \\ArrayIterator(is_array($this->%1$s) ? $this->%1$s : []);',
$firstProperty->getName()
),
'returntype' => 'ArrayIterator',
'docblock' => DocBlockGeneratorFactory::fromArray([
'tags' => [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Phpro\SoapClient\CodeGenerator\Context\ContextInterface;
use Phpro\SoapClient\CodeGenerator\Context\TypeContext;
use Phpro\SoapClient\CodeGenerator\Model\Type;
use Phpro\SoapClient\CodeGenerator\LaminasCodeFactory\DocBlockGeneratorFactory;
use Phpro\SoapClient\Exception\AssemblerException;
use Laminas\Code\Generator\ClassGenerator;
use Laminas\Code\Generator\MethodGenerator;
Expand Down Expand Up @@ -61,14 +60,7 @@ private function implementJsonSerialize(Type $type, ClassGenerator $class)
'parameters' => [],
'visibility' => MethodGenerator::VISIBILITY_PUBLIC,
'body' => $this->generateJsonSerializeBody($type, $class),
'docblock' => DocBlockGeneratorFactory::fromArray([
'tags' => [
[
'name' => 'return',
'description' => 'array'
]
]
])
'returntype' => 'array',
])
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MyType implements IteratorAggregate
* @phpstan-return \ArrayIterator<array-key, array>
* @psalm-return \ArrayIterator<array-key, array>
*/
public function getIterator()
public function getIterator() : \ArrayIterator
{
return new \ArrayIterator(is_array(\$this->prop1) ? \$this->prop1 : []);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ function it_assembles_a_type()
class MyType implements JsonSerializable
{
/**
* @return array
*/
public function jsonSerialize()
public function jsonSerialize() : array
{
return [
'prop1' => \$this->prop1,
Expand Down

0 comments on commit e47ea71

Please sign in to comment.