Skip to content

Commit f7c6d43

Browse files
committed
PHP 8.1 Implementation
1 parent 9de7b29 commit f7c6d43

File tree

7 files changed

+26
-17
lines changed

7 files changed

+26
-17
lines changed

.github/workflows/phpunit.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ jobs:
1616
strategy:
1717
matrix:
1818
php-version:
19+
- "8.3"
1920
- "8.2"
2021
- "8.1"
21-
- "8.0"
22-
- "7.4"
2322

2423
steps:
2524
- uses: actions/checkout@v4

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
"ByJG\\DesignPattern\\": "src/"
77
}
88
},
9+
"autoload-dev": {
10+
"psr-4": {
11+
"Tests\\": "tests/"
12+
}
13+
},
914
"require": {
10-
"php": ">=7.4"
15+
"php": ">=8.1"
1116
},
1217
"require-dev": {
13-
"phpunit/phpunit": "5.7.*|7.4.*|^9.5"
18+
"phpunit/phpunit": "^9.6"
1419
},
1520
"license": "MIT"
1621
}

src/Singleton.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __wakeup()
3636
/**
3737
* @return static
3838
*/
39-
public static function getInstance()
39+
public static function getInstance(): static
4040
{
4141
static $instances;
4242

src/SingletonException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace ByJG\DesignPattern;
44

5-
class SingletonException extends \Exception
5+
use Exception;
6+
7+
class SingletonException extends Exception
68
{
79

810
}

tests/Sample1.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php
22

3-
require_once __DIR__ . "/../vendor/autoload.php";
3+
namespace Tests;
4+
5+
use ByJG\DesignPattern\Singleton;
46

57
class Sample1
68
{
7-
use \ByJG\DesignPattern\Singleton;
9+
use Singleton;
810

9-
public $property;
11+
public int $property;
1012

1113
private function __construct()
1214
{

tests/Sample2.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
22

3-
require_once __DIR__ . "/../vendor/autoload.php";
3+
namespace Tests;
4+
5+
use ByJG\DesignPattern\Singleton;
46

57
class Sample2
68
{
7-
use \ByJG\DesignPattern\Singleton;
9+
use Singleton;
810

9-
public $property2;
11+
public int $property2;
1012
}

tests/SingletonTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?php
22

3-
use ByJG\DesignPattern\SingletonException;
3+
namespace Tests;
44

5-
require_once __DIR__ . "/../vendor/autoload.php";
6-
require_once "Sample1.php";
7-
require_once "Sample2.php";
5+
use ByJG\DesignPattern\SingletonException;
6+
use PHPUnit\Framework\TestCase;
87

9-
class SingletonTest extends \PHPUnit\Framework\TestCase
8+
class SingletonTest extends TestCase
109
{
1110
public function testSingleton()
1211
{

0 commit comments

Comments
 (0)