forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-turbo-add-more-types.diff
100 lines (87 loc) · 3.2 KB
/
pre-turbo-add-more-types.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
diff --git a/src/Form/AddItemToCartFormType.php b/src/Form/AddItemToCartFormType.php
index 9611bb3..1c131f4 100644
--- a/src/Form/AddItemToCartFormType.php
+++ b/src/Form/AddItemToCartFormType.php
@@ -14,7 +14,7 @@ use Symfony\Component\Routing\RouterInterface;
class AddItemToCartFormType extends AbstractType
{
- private $router;
+ private RouterInterface $router;
public function __construct(RouterInterface $router)
{
diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php
index f9cf337..4937051 100644
--- a/src/Repository/ProductRepository.php
+++ b/src/Repository/ProductRepository.php
@@ -25,7 +25,7 @@ class ProductRepository extends ServiceEntityRepository
*
* @return Product[]
*/
- public function search(?Category $category, ?string $term)
+ public function search(?Category $category, ?string $term): array
{
$qb = $this->createQueryBuilder('product');
diff --git a/src/Service/CartStorage.php b/src/Service/CartStorage.php
index c1f323a..9dd35cc 100644
--- a/src/Service/CartStorage.php
+++ b/src/Service/CartStorage.php
@@ -11,9 +11,9 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
class CartStorage
{
- private $requestStack;
- private $productRepository;
- private $colorRepository;
+ private RequestStack $requestStack;
+ private ProductRepository $productRepository;
+ private ColorRepository $colorRepository;
public function __construct(RequestStack $requestStack, ProductRepository $productRepository, ColorRepository $colorRepository)
{
@@ -54,12 +54,12 @@ class CartStorage
return $this->getCart() ?: new Cart();
}
- public function save(Cart $cart)
+ public function save(Cart $cart): void
{
$this->getSession()->set(self::getKey(), $cart);
}
- public function clearCart()
+ public function clearCart(): void
{
$this->getSession()->remove(self::getKey());
}
diff --git a/src/Twig/CartExtension.php b/src/Twig/CartExtension.php
index 7c354eb..66d6af3 100644
--- a/src/Twig/CartExtension.php
+++ b/src/Twig/CartExtension.php
@@ -12,14 +12,14 @@ use Twig\TwigFunction;
class CartExtension extends AbstractExtension
{
- private $cartStorage;
+ private CartStorage $cartStorage;
public function __construct(CartStorage $cartStorage)
{
$this->cartStorage = $cartStorage;
}
- public function getFunctions()
+ public function getFunctions(): array
{
return [
new TwigFunction('count_cart_items', [$this, 'countCartItems']),
diff --git a/src/Twig/SerializeExtension.php b/src/Twig/SerializeExtension.php
index c6a1124..7b9980f 100644
--- a/src/Twig/SerializeExtension.php
+++ b/src/Twig/SerializeExtension.php
@@ -8,14 +8,14 @@ use Twig\TwigFilter;
class SerializeExtension extends AbstractExtension
{
- private $serializer;
+ private SerializerInterface $serializer;
public function __construct(SerializerInterface $serializer)
{
$this->serializer = $serializer;
}
- public function getFilters()
+ public function getFilters(): array
{
return [
new TwigFilter('serialize', [$this, 'serialize']),