Skip to content

Commit

Permalink
Add stubs for Symfony 7 (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
HypeMC authored Jun 22, 2024
1 parent 465f8e2 commit 353c9b0
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Symfony\Bundle\FrameworkBundle\Controller;

use Symfony\Contracts\Service\ServiceSubscriberInterface;
use Psr\Container\ContainerInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormTypeInterface;

abstract class AbstractController implements ServiceSubscriberInterface
{
/**
* @psalm-suppress PropertyNotSetInConstructor
*/
protected ContainerInterface $container;

/**
* @template TData
* @template TFormType of FormTypeInterface<TData>
*
* @psalm-param class-string<TFormType> $type
*
* @psalm-return FormInterface<TData>
*/
protected function createForm(string $type, mixed $data = null, array $options = []): FormInterface {}
}
32 changes: 32 additions & 0 deletions src/Stubs/7/Component/HttpFoundation/InputBag.stubphp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Symfony\Component\HttpFoundation;

/**
* @template T of string|int|float|bool
*/
final class InputBag extends ParameterBag
{
/**
* Returns a string input value by name.
*
* @template D of T|null
* @psalm-param D $default
* @psalm-return D|T
* @psalm-taint-source input
* @psalm-mutation-free
*/
public function get(string $key, mixed $default = null): string|int|float|bool|null {}

/**
* Returns the parameters.
*
* @param string|null $key The name of the parameter to return or null to get them all
*
* @return array An array of parameters
*
* @psalm-taint-source input
* @psalm-mutation-free
*/
public function all(?string $key = null): array {}
}
30 changes: 30 additions & 0 deletions src/Stubs/7/Component/HttpFoundation/ParameterBag.stubphp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Symfony\Component\HttpFoundation;

class ParameterBag implements \IteratorAggregate, \Countable
{
/**
* Returns a parameter by name.
*
* @param string $key The key
* @param mixed $default The default value if the parameter key does not exist
*
* @return mixed
* @psalm-taint-source input
* @psalm-mutation-free
*/
public function get(string $key, mixed $default = null): mixed {}

/**
* Returns the parameters.
*
* @param string|null $key The name of the parameter to return or null to get them all
*
* @return array An array of parameters
*
* @psalm-taint-source input
* @psalm-mutation-free
*/
public function all(?string $key = null): array {}
}
21 changes: 21 additions & 0 deletions src/Stubs/7/Component/HttpFoundation/Request.stubphp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Symfony\Component\HttpFoundation;

class Request
{
/**
* @psalm-var InputBag
*/
public InputBag $request;

/**
* @psalm-var InputBag<string>
*/
public InputBag $query;

/**
* @psalm-var InputBag<string>
*/
public InputBag $cookies;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Symfony\Component\Serializer\Normalizer;

interface DenormalizerInterface
{
/**
* @template TObject of object
* @template TType of string|class-string<TObject>
*
* @psalm-param TType $type
* @psalm-return (TType is class-string<TObject> ? TObject : mixed)
*/
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed;
}

0 comments on commit 353c9b0

Please sign in to comment.