Skip to content

Commit

Permalink
Merge branch 'release/1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmikita committed Jan 25, 2022
2 parents 566fbb8 + 8585ae8 commit 594b5a8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.0.0] - 06.01.2020
## 1.1.1

Fixed return comment so class can be properly analysed by PHPStan

## 1.1.0

Added arguments passing from `get` method to constructor

## 1.0.0

Initial release
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
[![Total Downloads](https://poser.pugx.org/micropackage/singleton/downloads)](https://packagist.org/packages/micropackage/singleton)
[![License](https://poser.pugx.org/micropackage/singleton/license)](https://packagist.org/packages/micropackage/singleton)

<p align="center">
<img src="https://bracketspace.com/extras/micropackage/micropackage-small.png" alt="Micropackage logo"/>
</p>

## 💾 Installation

``` bash
Expand All @@ -15,7 +19,7 @@ composer require micropackage/singleton
## 🕹 Usage

```php
use Micropackage\Singleton;
use Micropackage\Singleton\Singleton;

class Example extends Singleton {}

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "micropackage/singleton",
"description": "Singleton implementation",
"version": "1.1.1",
"license": "GPL-3.0-or-later",
"authors": [
{
Expand Down
5 changes: 3 additions & 2 deletions src/Singleton.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ public function __wakeup() {
* Gets the instance
*
* @since 1.0.0
* @return Singleton
* @return static
*/
public static function get() {
$class = get_called_class();
$args = func_get_args();

if ( ! isset( self::$instances[ $class ] ) ) {
self::$instances[ $class ] = new static();
self::$instances[ $class ] = new static( ...$args );
}

return self::$instances[ $class ];
Expand Down

0 comments on commit 594b5a8

Please sign in to comment.