@@ -562,7 +562,7 @@ namespace Some\Namespace;
562
562
563
563
// ...
564
564
565
- public function setSomething(\Vendor\Namespace\Entity\Value $value);
565
+ public function setSomething(\Vendor\Namespace\Entity\Value $value): self ;
566
566
```
567
567
568
568
Right:
@@ -574,7 +574,7 @@ namespace Some\Namespace;
574
574
575
575
use Vendor\Namespace\Entity\Value;
576
576
577
- public function setSomething(Value $value);
577
+ public function setSomething(Value $value): self ;
578
578
```
579
579
580
580
## Usage of PHP features
@@ -746,7 +746,7 @@ Wrong:
746
746
``` php
747
747
<?php
748
748
749
- function getSomething(): string
749
+ function getSomething(): ? string
750
750
{
751
751
$a = get();
752
752
return $a;
@@ -758,7 +758,7 @@ Correct:
758
758
``` php
759
759
<?php
760
760
761
- function getSomething(): string
761
+ function getSomething(): ? string
762
762
{
763
763
return get();
764
764
}
@@ -1025,6 +1025,8 @@ function getValue(MyObject $object): string
1025
1025
return $object->get();
1026
1026
}
1027
1027
/**
1028
+ * @param int $requestId
1029
+ * @return bool
1028
1030
* @throws PaybackUnavailableException
1029
1031
*/
1030
1032
function payback(int $requestId): bool
@@ -1053,9 +1055,10 @@ function getValue(MyObject $object): ?string
1053
1055
return $object->get();
1054
1056
}
1055
1057
/**
1058
+ * @param int $requestId
1056
1059
* @throws PaybackUnavailableException
1057
1060
*/
1058
- function payback($requestId): void
1061
+ function payback(int $requestId): void
1059
1062
{
1060
1063
makePayback($requestId);
1061
1064
}
@@ -1116,10 +1119,7 @@ declare(strict_types=1);
1116
1119
1117
1120
class SomeClass
1118
1121
{
1119
- /**
1120
- * @var Child|null
1121
- */
1122
- private $child;
1122
+ private ?Child $child;
1123
1123
1124
1124
public function getChild(): Child
1125
1125
{
@@ -1688,24 +1688,24 @@ any of parameters in the code itself.
1688
1688
For example, instead of:
1689
1689
1690
1690
``` php
1691
- class ServiceA
1691
+ class ServiceAlpha
1692
1692
{
1693
1693
public function doSomething(): void
1694
1694
{
1695
1695
$alpha = Manager::getInstance();
1696
1696
$alpha->doSomething('a');
1697
1697
}
1698
1698
}
1699
- class ServiceB
1699
+ class ServiceBeta
1700
1700
{
1701
1701
public function doSomething(): void
1702
1702
{
1703
1703
$alpha = Manager::getInstance();
1704
1704
$alpha->doSomething('b');
1705
1705
}
1706
1706
}
1707
- $alpha = new ServiceA ();
1708
- $beta = new ServiceB ();
1707
+ $alpha = new ServiceAlpha ();
1708
+ $beta = new ServiceBeta ();
1709
1709
```
1710
1710
1711
1711
we use:
@@ -3328,6 +3328,14 @@ class UserData
3328
3328
private string $email;
3329
3329
private string $name;
3330
3330
3331
+ public function __construct(
3332
+ string $email,
3333
+ string $name
3334
+ ) {
3335
+ $this->email = $email;
3336
+ $this->name = $name;
3337
+ }
3338
+
3331
3339
public function getEmail(): string
3332
3340
{
3333
3341
return $this->email;
0 commit comments