Skip to content

Commit 68d16fd

Browse files
authored
Merge pull request #5 from josantonius/release/v2.0.3
Release/v2.0.3
2 parents 9ac448c + 2c87365 commit 68d16fd

17 files changed

+187
-158
lines changed

.github/lang/es-ES/README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ Biblioteca para manejo de hooks en PHP.
3434

3535
## Requisitos
3636

37-
Esta biblioteca es compatible con las versiones de PHP: 8.1.
37+
- Sistema operativo: Linux | Windows.
38+
39+
- Versiones de PHP: 8.1 | 8.2.
3840

3941
## Instalación
4042

@@ -62,44 +64,40 @@ git clone https://github.com/josantonius/php-hook.git
6264

6365
### Instancia Action
6466

65-
```php
66-
use Josantonius\Hook\Action;
67-
```
67+
`Josantonius\Hook\Action`
6868

6969
Obtener el nivel de prioridad de la acción:
7070

7171
```php
72-
$action->getPriority(): int
72+
public function getPriority(): int;
7373
```
7474

7575
Obtener el resultado de la llamada a la acción:
7676

7777
```php
78-
$action->getResult(): mixed
78+
public function getResult(): mixed;
7979
```
8080

8181
Comprueba si la acción se realiza solo una vez:
8282

8383
```php
84-
$action->isOnce(): bool
84+
public function isOnce(): bool;
8585
```
8686

8787
Comprueba si la acción ya se ha realizado:
8888

8989
```php
90-
$action->wasDone(): bool
90+
public function wasDone(): bool;
9191
```
9292

9393
### Clase Hook
9494

95-
```php
96-
use Josantonius\Hook\Hook;
97-
```
95+
`Josantonius\Hook\Hook`
9896

9997
Registrar nuevo gancho:
10098

10199
```php
102-
$hook = new Hook(string $name);
100+
public function __construct(private string $name);
103101
```
104102

105103
Agregar acción en el gancho:
@@ -112,7 +110,7 @@ Agregar acción en el gancho:
112110
*
113111
* @return Action Acción agregada.
114112
*/
115-
$hook->addAction(callable $callback, int $priority = Priority::NORMAL): Action
113+
public function addAction(callable $callback, int $priority = Priority::NORMAL): Action;
116114
```
117115

118116
Agregar acción en el gancho una vez:
@@ -126,7 +124,7 @@ Agregar acción en el gancho una vez:
126124
*
127125
* @return Action Acción agregada.
128126
*/
129-
$hook->addActionOnce(callable $callback, int $priority = Priority::NORMAL): Action
127+
public function addActionOnce(callable $callback, int $priority = Priority::NORMAL): Action;
130128
```
131129

132130
Ejecutar las acciones agregadas al gancho:
@@ -138,7 +136,7 @@ Ejecutar las acciones agregadas al gancho:
138136
*
139137
* @return Action[] Acciones hechas.
140138
*/
141-
$hook->doActions(mixed ...$arguments): Action[]
139+
public function doActions(mixed ...$arguments): array;
142140
```
143141

144142
Comprueba si el gancho tiene acciones:
@@ -148,7 +146,7 @@ Comprueba si el gancho tiene acciones:
148146
* Verdadero si el gancho tiene alguna acción incluso si la acción
149147
* se ha hecho antes (acciones recurrentes creadas con addAction).
150148
*/
151-
$hook->hasActions(): bool
149+
public function hasActions(): bool;
152150
```
153151

154152
Comprueba si el gancho tiene acciones sin realizar:
@@ -157,7 +155,7 @@ Comprueba si el gancho tiene acciones sin realizar:
157155
/**
158156
* Verdadero si el gancho tiene alguna acción sin realizar.
159157
*/
160-
$hook->hasUndoneActions(): bool
158+
public function hasUndoneActions(): bool;
161159
```
162160

163161
Comprueba si las acciones se han realizado al menos una vez:
@@ -166,25 +164,27 @@ Comprueba si las acciones se han realizado al menos una vez:
166164
/**
167165
* Si doActions fue ejecutado al menos una vez.
168166
*/
169-
$hook->hasDoneActions(): bool
167+
public function hasDoneActions(): bool;
170168
```
171169

172170
Obtener el nombre del hook:
173171

174172
```php
175-
$hook->getName(): string
173+
public function getName(): string;
176174
```
177175

178-
### Priority Class
176+
### Clase Priority
177+
178+
`Josantonius\Hook\Priority`
179179

180180
Constantes disponibles:
181181

182182
```php
183-
Priority::HIGHEST; // 50
184-
Priority::HIGH; // 100
185-
Priority::NORMAL; // 150
186-
Priority::LOW; // 200
187-
Priority::LOWEST; // 250
183+
public const HIGHEST = 50;
184+
public const HIGH = 100;
185+
public const NORMAL = 150;
186+
public const LOW = 200;
187+
public const LOWEST = 250;
188188
```
189189

190190
## Excepciones utilizadas

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ jobs:
4343
name: 'PHPUnit (PHP ${{ matrix.php }} - ${{ matrix.system }})'
4444
strategy:
4545
matrix:
46-
system: ['ubuntu-latest']
46+
system: ['ubuntu-latest', 'windows-latest']
4747
php:
4848
- '8.1'
49+
- '8.2'
4950
steps:
5051
- name: Checkout Code
5152
uses: actions/checkout@v3

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# CHANGELOG
22

3+
## [v2.0.3](https://github.com/josantonius/php-hook/releases/tag/v2.0.3) (2022-09-29)
4+
5+
* The notation type in the test function names has been changed from camel to snake case for readability.
6+
7+
* Functions were added to document the methods and avoid confusion.
8+
9+
* Disabled the ´CamelCaseMethodName´ rule in ´phpmd.xml´ to avoid warnings about function names in tests.
10+
11+
* The alignment of the asterisks in the comments has been fixed.
12+
13+
* Tests for Windows have been added.
14+
15+
* Tests for PHP 8.2 have been added.
16+
317
## [v2.0.2](https://github.com/josantonius/php-hook/releases/tag/v2.0.2) (2022-08-11)
418

519
* Improved documentation.

README.md

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ Library for handling hooks in PHP.
2727
- [TODO](#todo)
2828
- [Changelog](#changelog)
2929
- [Contribution](#contribution)
30-
- [Sponsor](#Sponsor)
30+
- [Sponsor](#sponsor)
3131
- [License](#license)
3232

3333
---
3434

3535
## Requirements
3636

37-
This library is compatible with the PHP versions: 8.1.
37+
- Operating System: Linux | Windows.
38+
39+
- PHP versions: 8.1 | 8.2.
3840

3941
## Installation
4042

@@ -63,44 +65,40 @@ git clone https://github.com/josantonius/php-hook.git
6365

6466
### Action Instance
6567

66-
```php
67-
use Josantonius\Hook\Action;
68-
```
68+
`Josantonius\Hook\Action`
6969

7070
Gets action priority:
7171

7272
```php
73-
$action->getPriority(): int
73+
public function getPriority(): int;
7474
```
7575

7676
Gets action callback result:
7777

7878
```php
79-
$action->getResult(): mixed
79+
public function getResult(): mixed;
8080
```
8181

8282
Checks if the action is done once:
8383

8484
```php
85-
$action->isOnce(): bool
85+
public function isOnce(): bool;
8686
```
8787

8888
Checks if the action has already been done:
8989

9090
```php
91-
$action->wasDone(): bool
91+
public function wasDone(): bool;
9292
```
9393

9494
### Hook Class
9595

96-
```php
97-
use Josantonius\Hook\Hook;
98-
```
96+
`Josantonius\Hook\Hook`
9997

10098
Register new hook:
10199

102100
```php
103-
$hook = new Hook(string $name);
101+
public function __construct(private string $name);
104102
```
105103

106104
Adds action on the hook:
@@ -113,7 +111,7 @@ Adds action on the hook:
113111
*
114112
* @return Action Added action.
115113
*/
116-
$hook->addAction(callable $callback, int $priority = Priority::NORMAL): Action
114+
public function addAction(callable $callback, int $priority = Priority::NORMAL): Action;
117115
```
118116

119117
Adds action once on the hook:
@@ -127,7 +125,7 @@ Adds action once on the hook:
127125
*
128126
* @return Action Added action.
129127
*/
130-
$hook->addActionOnce(callable $callback, int $priority = Priority::NORMAL): Action
128+
public function addActionOnce(callable $callback, int $priority = Priority::NORMAL): Action;
131129
```
132130

133131
Runs the added actions for the hook:
@@ -139,7 +137,7 @@ Runs the added actions for the hook:
139137
*
140138
* @return Action[] Done actions.
141139
*/
142-
$hook->doActions(mixed ...$arguments): Action[]
140+
public function doActions(mixed ...$arguments): array;
143141
```
144142

145143
Checks if the hook has actions:
@@ -149,7 +147,7 @@ Checks if the hook has actions:
149147
* True if the hook has any action even if the action has been
150148
* done before (recurring actions created with addAction).
151149
*/
152-
$hook->hasActions(): bool
150+
public function hasActions(): bool;
153151
```
154152

155153
Checks if the hook has undone actions:
@@ -158,7 +156,7 @@ Checks if the hook has undone actions:
158156
/**
159157
* True if the hook has some action left undone.
160158
*/
161-
$hook->hasUndoneActions(): bool
159+
public function hasUndoneActions(): bool;
162160
```
163161

164162
Checks if the actions were done at least once:
@@ -167,29 +165,27 @@ Checks if the actions were done at least once:
167165
/**
168166
* If doActions was executed at least once.
169167
*/
170-
$hook->hasDoneActions(): bool
168+
public function hasDoneActions(): bool;
171169
```
172170

173171
Gets hook name:
174172

175173
```php
176-
$hook->getName(): string
174+
public function getName(): string;
177175
```
178176

179177
### Priority Class
180178

181-
```php
182-
use Josantonius\Hook\Priority;
183-
```
179+
`Josantonius\Hook\Priority`
184180

185181
Available constants:
186182

187183
```php
188-
Priority::HIGHEST; // 50
189-
Priority::HIGH; // 100
190-
Priority::NORMAL; // 150
191-
Priority::LOW; // 200
192-
Priority::LOWEST; // 250
184+
public const HIGHEST = 50;
185+
public const HIGH = 100;
186+
public const NORMAL = 150;
187+
public const LOW = 200;
188+
public const LOWEST = 250;
193189
```
194190

195191
## Exceptions Used

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"htmlCoverage": "vendor/bin/phpunit --coverage-html coverage",
5858
"phpcs": "vendor/bin/phpcs --standard=phpcs.xml $(find . -name '*.php');",
5959
"phpmd": "vendor/bin/phpmd src,tests text ./phpmd.xml",
60-
"phpunit": "vendor/bin/phpunit --colors=always;",
60+
"phpunit": "vendor/bin/phpunit",
6161
"tests": [
6262
"clear",
6363
"@phpmd",

phpmd.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?xml version="1.0"?>
2-
<ruleset name="PHPMD rule set" xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
2+
<ruleset name="PHPMD rule set"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
35
http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="
46
http://pmd.sf.net/ruleset_xml_schema.xsd">
57
<description>Coding standard.</description>
@@ -30,7 +32,7 @@
3032
<rule ref="rulesets/controversial.xml/Superglobals" />
3133
<rule ref="rulesets/controversial.xml/CamelCaseClassName" />
3234
<rule ref="rulesets/controversial.xml/CamelCasePropertyName" />
33-
<rule ref="rulesets/controversial.xml/CamelCaseMethodName" />
35+
<!--<rule ref="rulesets/controversial.xml/CamelCaseMethodName"/>-->
3436
<rule ref="rulesets/controversial.xml/CamelCaseParameterName" />
3537
<rule ref="rulesets/controversial.xml/CamelCaseVariableName" />
3638

src/Action.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
declare(strict_types=1);
44

55
/*
6-
* This file is part of https://github.com/josantonius/php-hook repository.
7-
*
8-
* (c) Josantonius <[email protected]>
9-
*
10-
* For the full copyright and license information, please view the LICENSE
11-
* file that was distributed with this source code.
12-
*/
6+
* This file is part of https://github.com/josantonius/php-hook repository.
7+
*
8+
* (c) Josantonius <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
1313

1414
namespace Josantonius\Hook;
1515

src/Hook.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
declare(strict_types=1);
44

55
/*
6-
* This file is part of https://github.com/josantonius/php-hook repository.
7-
*
8-
* (c) Josantonius <[email protected]>
9-
*
10-
* For the full copyright and license information, please view the LICENSE
11-
* file that was distributed with this source code.
12-
*/
6+
* This file is part of https://github.com/josantonius/php-hook repository.
7+
*
8+
* (c) Josantonius <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
1313

1414
namespace Josantonius\Hook;
1515

0 commit comments

Comments
 (0)