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

Update PHP version to 7.1 minimum. #22

Open
wants to merge 4 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
7 changes: 3 additions & 4 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 All @@ -8,7 +10,7 @@
*
* New BSD License
*
* Copyright © 2007-2017, Hoa community. All rights reserved.
* Copyright © 2007-2018, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
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
45 changes: 8 additions & 37 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 All @@ -8,7 +10,7 @@
*
* New BSD License
*
* Copyright © 2007-2017, Hoa community. All rights reserved.
* Copyright © 2007-2018, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -43,25 +45,18 @@
* 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
*/
private static $_instance = null;



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

/**
* Get instance of \Hoa\Registry.
*
* @return object
*/
protected static function getInstance()
protected static function getInstance(): object
{
if (null === static::$_instance) {
static::$_instance = new parent();
Expand All @@ -91,12 +84,8 @@ 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)
public static function set($index, $value): void
{
static::getInstance()->offsetSet($index, $value);

Expand All @@ -105,10 +94,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,22 +112,16 @@ 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)
public static function remove($index): void
{
static::getInstance()->offsetUnset($index);

Expand All @@ -154,28 +133,20 @@ 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
{
/**
* Component's name.
*
* @var string
*/
protected $_name = 'Registry';



/**
* ID of the component.
*
* @param string $id ID of the component.
* @return mixed
*/
public function reachId($id)
public function reachId(string $id)
{
return Registry::get($id);
}
Expand Down
21 changes: 10 additions & 11 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 All @@ -8,7 +10,7 @@
*
* New BSD License
*
* Copyright © 2007-2017, Hoa community. All rights reserved.
* Copyright © 2007-2018, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -43,22 +45,19 @@
* 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
{
public function case_no_instance()
public function case_no_instance(): void
{
$this
->exception(function () {
->exception(function (): void {
new LUT();
})
->isInstanceOf('Hoa\Registry\Exception');
}

public function case_classic()
public function case_classic(): void
{
$this
->given(
Expand All @@ -73,7 +72,7 @@ public function case_classic()
->isEqualTo($value);
}

public function case_value_is_an_object()
public function case_value_is_an_object(): void
{
$this
->given(
Expand All @@ -90,7 +89,7 @@ public function case_value_is_an_object()
->isIdenticalTo($value);
}

public function case_isRegistered()
public function case_isRegistered(): void
{
$this
->given(
Expand Down Expand Up @@ -120,7 +119,7 @@ public function case_isRegistered()
->isFalse();
}

public function case_protocol()
public function case_protocol(): void
{
$this
->given(
Expand All @@ -135,7 +134,7 @@ public function case_protocol()
->isEqualTo($value);
}

public function case_value_protocol_and_references()
public function case_value_protocol_and_references(): void
{
$this
->given(
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