Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

chore(php) Move to PHP 7.1 #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion .State

This file was deleted.

5 changes: 2 additions & 3 deletions Exception.php → Source/Exception.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Hoa
*
Expand Down Expand Up @@ -42,9 +44,6 @@
* Class \Hoa\Registry\Exception.
*
* Extending the \Hoa\Exception\Exception class.
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Exception extends HoaException
{
Expand Down
37 changes: 6 additions & 31 deletions Registry.php → Source/Registry.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Hoa
*
Expand Down Expand Up @@ -43,25 +45,20 @@
* Class \Hoa\Registry.
*
* Hold a register of something.
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Registry extends \ArrayObject
{
/**
* Instance.
*
* @var \Hoa\Registry
* @var self
*/
private static $_instance = null;



/**
* Private constructor.
*
* @throws \Hoa\Registry\Exception
*/
public function __construct()
{
Expand All @@ -77,10 +74,8 @@ public function __construct()

/**
* Get instance of \Hoa\Registry.
*
* @return object
*/
protected static function getInstance()
protected static function getInstance(): parent
{
if (null === static::$_instance) {
static::$_instance = new parent();
Expand All @@ -91,10 +86,6 @@ protected static function getInstance()

/**
* Set a new registry.
*
* @param mixed $index Index of registry.
* @param mixed $value Value of registry.
* @return void
*/
public static function set($index, $value)
{
Expand All @@ -105,10 +96,6 @@ public static function set($index, $value)

/**
* Get a registry.
*
* @param mixed $index Index of registry.
* @return mixed
* @throws \Hoa\Registry\Exception
*/
public static function get($index)
{
Expand All @@ -127,20 +114,14 @@ public static function get($index)

/**
* Check if an index is registered.
*
* @param mixed $index Index of registry.
* @return bool
*/
public static function isRegistered($index)
public static function isRegistered($index): bool
{
return static::getInstance()->offsetExists($index);
}

/**
* Unset an registry.
*
* @param mixed $index Index of registry.
* @return void
*/
public static function remove($index)
{
Expand All @@ -154,9 +135,6 @@ public static function remove($index)
* Class \Hoa\Registry\_Protocol.
*
* The `hoa://Library/Registry` node.
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class _Protocol extends Protocol\Node
{
Expand All @@ -171,9 +149,6 @@ class _Protocol extends Protocol\Node

/**
* ID of the component.
*
* @param string $id ID of the component.
* @return mixed
*/
public function reachId($id)
{
Expand All @@ -184,7 +159,7 @@ public function reachId($id)
/**
* Flex entity.
*/
Consistency::flexEntity('Hoa\Registry\Registry');
Consistency::flexEntity(Registry::class);

/**
* Add the `hoa://Library/Registry` node. Should be use to reach/get an entry
Expand Down
7 changes: 3 additions & 4 deletions Test/Unit/Registry.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Hoa
*
Expand Down Expand Up @@ -43,9 +45,6 @@
* Class \Hoa\Registry\Test\Unit\Registry.
*
* Test suite of the registry.
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Registry extends Test\Unit\Suite
{
Expand All @@ -55,7 +54,7 @@ public function case_no_instance()
->exception(function () {
new LUT();
})
->isInstanceOf('Hoa\Registry\Exception');
->isInstanceOf(LUT\Exception::class);
}

public function case_classic()
Expand Down
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@
"source": "https://central.hoa-project.net/Resource/Library/Registry"
},
"require": {
"php" : ">=5.5.0",
"hoa/consistency": "~1.0",
"hoa/exception" : "~1.0",
"hoa/protocol" : "~1.0"
"php" : ">=7.1",
"hoa/consistency": "dev-master",
"hoa/exception" : "dev-master",
"hoa/protocol" : "dev-master"
},
"require-dev": {
"hoa/test": "~2.0"
"hoa/test": "dev-master"
},
"autoload": {
"psr-4": {
"Hoa\\Registry\\": "."
"Hoa\\Registry\\": "Source",
"Hoa\\Registry\\Test\\": "Test"
}
},
"extra": {
Expand Down