Skip to content

PHP 8.1 Implementation #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: byjg
4 changes: 2 additions & 2 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ jobs:
strategy:
matrix:
php-version:
- "8.3"
- "8.2"
- "8.1"
- "8.0"
- "7.4"

steps:
- uses: actions/checkout@v4
- run: composer install
- run: ./vendor/bin/phpunit
- run: ./vendor/bin/psalm

Documentation:
if: github.ref == 'refs/heads/master'
Expand Down
6 changes: 6 additions & 0 deletions .run/PHPUnit.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="PHPUnit" type="PHPUnitRunConfigurationType" factoryName="PHPUnit">
<TestRunner configuration_file="$PROJECT_DIR$/phpunit.xml.dist" scope="XML" use_alternative_configuration_file="true" />
<method v="2" />
</configuration>
</component>
5 changes: 5 additions & 0 deletions .run/PSalm.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="PSalm" type="PhpLocalRunConfigurationType" factoryName="PHP Console" path="$PROJECT_DIR$/vendor/bin/psalm">
<method v="2" />
</configuration>
</component>
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
"ByJG\\DesignPattern\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"require": {
"php": ">=7.4"
"php": ">=8.1 <8.4"
},
"require-dev": {
"phpunit/phpunit": "5.7.*|7.4.*|^9.5"
"phpunit/phpunit": "^9.6",
"vimeo/psalm": "^5.9"
},
"license": "MIT"
}
18 changes: 18 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
resolveFromConfigFile="true"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<directory name="tests" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
2 changes: 1 addition & 1 deletion src/Singleton.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __wakeup()
/**
* @return static
*/
public static function getInstance()
public static function getInstance(): static
{
static $instances;

Expand Down
4 changes: 3 additions & 1 deletion src/SingletonException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace ByJG\DesignPattern;

class SingletonException extends \Exception
use Exception;

class SingletonException extends Exception
{

}
8 changes: 5 additions & 3 deletions tests/Sample1.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php

require_once __DIR__ . "/../vendor/autoload.php";
namespace Tests;

use ByJG\DesignPattern\Singleton;

class Sample1
{
use \ByJG\DesignPattern\Singleton;
use Singleton;

public $property;
public int $property;

private function __construct()
{
Expand Down
8 changes: 5 additions & 3 deletions tests/Sample2.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

require_once __DIR__ . "/../vendor/autoload.php";
namespace Tests;

use ByJG\DesignPattern\Singleton;

class Sample2
{
use \ByJG\DesignPattern\Singleton;
use Singleton;

public $property2;
public int $property2;
}
9 changes: 4 additions & 5 deletions tests/SingletonTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php

use ByJG\DesignPattern\SingletonException;
namespace Tests;

require_once __DIR__ . "/../vendor/autoload.php";
require_once "Sample1.php";
require_once "Sample2.php";
use ByJG\DesignPattern\SingletonException;
use PHPUnit\Framework\TestCase;

class SingletonTest extends \PHPUnit\Framework\TestCase
class SingletonTest extends TestCase
{
public function testSingleton()
{
Expand Down