Last active
January 28, 2022 10:44
-
-
Save michitheonlyone/ae925e607b78e19fe81512330a4b8efc to your computer and use it in GitHub Desktop.
PHP 8 new Dependency Injection vs PHP 7.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare(strict_types=1); | |
// PHP 8 | |
final class DependencyInjectionExampleNew | |
{ | |
public function __construct(private string $var) {} | |
} | |
// PHP 7.4 | |
final class DependencyInjectionExample | |
{ | |
private string $var; | |
public function __construct(string $var) | |
{ | |
$this->var = $this->var; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment