@@ -224,7 +224,7 @@ As you can see above there should be one space on both sides of equals sign (=).
224224Example of a method definition:
225225
226226``` php
227- public function someFunction($arg1, $arg2 = '')
227+ public function someFunction(string $arg1, string $arg2 = ''): mixed
228228{
229229 if (expr) {
230230 statement;
@@ -239,7 +239,7 @@ Try to make your functions return something, at least `true` or `false`, so
239239it can be determined whether the function call was successful:
240240
241241``` php
242- public function connection($dns, $persistent = false)
242+ public function connection(string|array $dns, bool $persistent = false): bool
243243{
244244 if (is_array($dns)) {
245245 $dnsInfo = $dns;
@@ -262,7 +262,7 @@ There are spaces on both side of the equals sign.
262262Try to avoid unnecessary nesting by bailing early:
263263
264264``` php
265- public function run(array $data)
265+ public function run(array $data): bool
266266{
267267 ...
268268 if (!$success) {
@@ -272,7 +272,7 @@ public function run(array $data)
272272 ...
273273}
274274
275- public function check(array $data)
275+ public function check(array $data): void
276276{
277277 ...
278278 if (!$success) {
@@ -299,7 +299,7 @@ We only typehint public methods, though, as typehinting is not cost-free:
299299 * @param callable $callback Some callback.
300300 * @param bool $boolean Some boolean value.
301301 */
302- public function foo(Table $table, array $array, callable $callback, $boolean)
302+ public function foo(Table $table, array $array, callable $callback, bool $boolean): void
303303{
304304}
305305```
@@ -317,7 +317,7 @@ type:
317317 *
318318 * @param array|\ArrayObject $array Some array value.
319319 */
320- public function foo($array)
320+ public function foo(array|\ArrayObject $array): void
321321{
322322}
323323```
@@ -456,7 +456,7 @@ instead:
456456 *
457457 * @return $this
458458 */
459- public function foo()
459+ public function foo(): static
460460{
461461 return $this;
462462}
@@ -650,7 +650,7 @@ class Thing
650650{
651651 private $property; // Defined
652652
653- public function readProperty()
653+ public function readProperty(): void
654654 {
655655 // Not recommended as the property is defined in the class
656656 if (!isset($this->property)) {
0 commit comments