Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stubs for Symfony 7 #352

Merged
merged 2 commits into from
Jun 22, 2024
Merged
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
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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it should be ok to return null as well, WDYT?

*/
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed;
}