Skip to content

Commit cf15dec

Browse files
committed
Merge branch 'dev'
2 parents dfe2f29 + 5cbe8d5 commit cf15dec

7 files changed

Lines changed: 23 additions & 142 deletions

File tree

.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
* text=auto
2+
* eol=lf
3+
4+
.git export-ignore
5+
.gitattributes export-ignore
6+
.gitignore export-ignore
7+
/.github export-ignore
8+
phpunit.xml export-ignore
9+
CHANGELOG.md export-ignore
10+
/tests export-ignore

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest, macos-latest, windows-latest]
12-
php: ['7.3', '7.4', '8.0']
12+
php: ['7.4', '8.0']
1313
dependency-version: [prefer-lowest, prefer-stable]
1414

1515
steps:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<a name="2.0.0"></a>
2+
# [2.0.0](https://github.com/atomastic/macroable) (2021-02-19)
3+
* Move to PHP 7.4
4+
15
<a name="1.0.0"></a>
26
# [1.0.0](https://github.com/atomastic/macroable) (2020-12-05)
37
* Initial release

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2020-2021 Sergey Romanenko
3+
Copyright (c) 2021 Sergey Romanenko
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ Macroable Component is a trait that, gives you the ability in effect to add new
99

1010
<br>
1111

12-
* [Installation](#installation)
13-
* [Usage](#usage)
14-
* [Methods](#methods)
15-
* [Tests](#tests)
16-
* [License](#license)
17-
1812
### Installation
1913

2014
#### With [Composer](https://getcomposer.org)
@@ -23,136 +17,9 @@ Macroable Component is a trait that, gives you the ability in effect to add new
2317
composer require atomastic/macroable
2418
```
2519

26-
### Usage
27-
28-
```php
29-
use Atomastic\Macroable\Macroable;
30-
```
31-
32-
### Methods
33-
34-
| Method | Description |
35-
|---|---|
36-
| <a href="#macroable_macro">`macro()`</a> | Register a custom macro. |
37-
| <a href="#macroable_mixin">`mixin()`</a> | Mix another object into the class. |
38-
| <a href="#macroable_hasMacro">`hasMacro()`</a> | Checks if macro is registered. |
39-
40-
#### Methods Details
41-
42-
##### <a name="macroable_macro"></a> Method: `macro()`
43-
44-
```php
45-
/**
46-
* Register a custom macro.
47-
*
48-
* @param string $name Name.
49-
* @param object|callable $macro Macro.
50-
* @return void
51-
*/
52-
public static function macro(string $name, $macro): void
53-
```
54-
55-
##### Example
56-
57-
```php
58-
$macroableClass = new class() {
59-
use Macroable;
60-
};
61-
62-
$macroableClass::macro('concatenate', function(... $strings) {
63-
return implode('-', $strings);
64-
});
65-
66-
$macroableClass::macro('message', function($name) {
67-
return 'Hello ' . $name;
68-
});
69-
70-
echo $macroableClass->concatenate('one', 'two', 'three');
71-
echo $macroableClass->message('Jack');
72-
```
73-
74-
##### The above example will output:
75-
76-
```
77-
one-two-three
78-
Hello Jack
79-
```
80-
81-
##### <a name="macroable_mixin"></a> Method: `mixin()`
20+
### Resources
21+
* [Documentation](https://atomastic.com/components/macroable)
8222

83-
```php
84-
/**
85-
* Mix another object into the class.
86-
*
87-
* @param object $mixin Mixin.
88-
* @param bool $replace Replace.
89-
* @return void
90-
*
91-
* @throws ReflectionException
92-
*/
93-
public static function mixin($mixin, bool $replace = true): void
94-
```
95-
96-
##### Example
97-
98-
```php
99-
$mixinClass = new class() {
100-
public function mixinMethod()
101-
{
102-
return function() {
103-
return 'mixinMethod';
104-
};
105-
}
106-
107-
public function anotherMixinMethod()
108-
{
109-
return function() {
110-
return 'anotherMixinMethod';
111-
};
112-
}
113-
};
114-
115-
$macroableClass->mixin($mixin);
116-
117-
$macroableClass->mixinMethod();
118-
$macroableClass->anotherMixinMethod();
119-
```
120-
121-
##### The above example will output:
122-
123-
```
124-
mixinMethod
125-
anotherMixinMethod
126-
```
127-
128-
129-
##### <a name="macroable_hasMacro"></a> Method: `hasMacro()`
130-
131-
```php
132-
/**
133-
* Checks if macro is registered.
134-
*
135-
* @param string $name Name
136-
* @return bool
137-
*/
138-
public static function hasMacro(string $name): bool
139-
```
140-
141-
##### Example
142-
143-
```php
144-
$macroableClass = new class() {
145-
use Macroable;
146-
};
147-
148-
$macroableClass::macro('message', function($name) {
149-
return 'Hello ' . $name;
150-
});
151-
152-
if ($macroableClass::hasMacro('message')) {
153-
// do something...
154-
}
155-
```
15623

15724
### Tests
15825

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^7.3 || ^8.0"
20+
"php": "^7.4 || ^8.0"
2121
},
2222
"autoload":{
2323
"psr-4": {
2424
"Atomastic\\Macroable\\": "src/"
2525
}
2626
},
2727
"require-dev": {
28-
"doctrine/coding-standard": "8.1.0",
29-
"pestphp/pest": "^0.3.3",
30-
"phpstan/phpstan": "^0.12.42"
28+
"doctrine/coding-standard": "8.2.0",
29+
"pestphp/pest": "^1.0.2",
30+
"phpstan/phpstan": "^0.12.77"
3131
}
3232
}

src/Macroable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ trait Macroable
1818
*
1919
* @var array
2020
*/
21-
protected static $macros = [];
21+
protected static array $macros = [];
2222

2323
/**
2424
* Register a custom macro.

0 commit comments

Comments
 (0)