Skip to content

Commit 32be00e

Browse files
php-simputils-109 Release of 1.1.3 (#110)
* php-simputils-109 Release of 1.1.3 Implemented nice functionality of batch/extract for `Box` Closes #108 * php-simputils-109 Release of 1.1.3 Some adjustments and implementations * php-simputils-109 Release of 1.1.3 Very promising code * php-simputils-109 Release of 1.1.3 Preparing for the release * php-simputils-109 Release of 1.1.3 Release is almost ready
1 parent 8db25d8 commit 32be00e

30 files changed

Lines changed: 1115 additions & 149 deletions

README.md

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,86 @@ I will be really happy hearing from you.
4242

4343
----
4444

45+
## Important notes
46+
1. Currently JSON serialization and deserialization does not work properly.
47+
Please do not rely on it for now! **IMPORTANT!**
48+
When fix for this problem comes, and you are using current logic - you might get
49+
into a broken code logic. Please do not use `\spaf\simputils\PHP::serialize()` and
50+
`\spaf\simputils\PHP::deserialize()` code with JSON mechanics, you can switch the
51+
mechanics to native PHP like this (workaround):
52+
```php
53+
PHP::$serialization_mechanism = PHP::SERIALIZATION_TYPE_PHP;
54+
PHP::init();
55+
```
56+
That will use native PHP mechanics for serialization, which should work properly
57+
starting from this release (1.1.3)
58+
4559
## Changelog
4660

61+
### 1.1.3
62+
63+
* Implemented method `\spaf\simputils\models\Box::batch()` that allows to easily export items
64+
of specified keys to the local variable scope
65+
* Implemented methods `setFromData()` and meta-magic methods `___serialize()` and
66+
`___deserialize()` to fix PHP native serialization/deserialization for the
67+
following classes:
68+
* `\spaf\simputils\models\Version`
69+
* `\spaf\simputils\models\UrlObject`
70+
* `\spaf\simputils\models\Time`
71+
* `\spaf\simputils\models\L10n`
72+
* `\spaf\simputils\models\IPv4Range`
73+
* `\spaf\simputils\models\IPv4`
74+
* `\spaf\simputils\models\File`
75+
* `\spaf\simputils\models\Dir`
76+
* `\spaf\simputils\models\DateTimeZone`
77+
* `\spaf\simputils\models\DateTime`
78+
* `\spaf\simputils\models\DatePeriod`
79+
* `\spaf\simputils\models\DateInterval`
80+
* `\spaf\simputils\models\Date`
81+
* `\spaf\simputils\models\DataUnit`
82+
* `\spaf\simputils\models\BigNumber`
83+
* Code Sniffer is removed from the project (got really annoyed, and it does not work correctly)
84+
* `\spaf\simputils\models\Time` and `\spaf\simputils\models\Date` have been refactored a bit.
85+
The caching mechanics has been fixed.
86+
* Additionally have been added the properties for `\spaf\simputils\models\Date`
87+
and `\spaf\simputils\models\Time` from the target `DateTime` object
88+
* `\spaf\simputils\models\Date` and `\spaf\simputils\models\Time` result of `for_system`
89+
now returns the whole DateTime string value of UTC, not only the date or time component.
90+
* Implemented `\spaf\simputils\generic\BasicExecEnvHandler` Execution-Environment (aka stages),
91+
besides that implemented `\spaf\simputils\generic\BasicInitConfig::@$ee` property that
92+
automatically will be assigned during `PHP::init()`, the object or params could be
93+
adjusted in the incoming config, example:
94+
```php
95+
$ic = PHP::init([
96+
'l10n' => 'AT',
97+
// 'ee' => new DummyExecEnvHandler(false, ee_name: 'TOO'),
98+
'ee' => [
99+
'ee' => 'test3-local',
100+
'is_hierarchical' => true,
101+
'permitted_values' => [
102+
'test1',
103+
'test2',
104+
'test3',
105+
'test4',
106+
]
107+
]
108+
]);
109+
pd("{$ic->ee}", Boolean::to($ic->ee->is('test4-local')));
110+
```
111+
For now not much of documentation is provided, but you always can define your own
112+
implementation of the class like `\spaf\simputils\components\execenvs\DummyExecEnvHandler`
113+
to handle your Exec-Env/stages implementation! More documentation and example will follow.
114+
* Additionally implemented `\spaf\simputils\components\execenvs\DummyExecEnvHandler`
115+
which is a dummy handler that just returns the predefined value. Should not be used
116+
on production.
117+
* Implemented `\spaf\simputils\exceptions\ExecEnvException` exception for Exec-Env cases
118+
* Implemented `\spaf\simputils\models\Box::popFromStart()` and
119+
`\spaf\simputils\models\Box::popFromEnd()` methods to get value from the box, return
120+
and remove it from the box.
121+
* Implemented tests for:
122+
* Exec-Env
123+
* Box batch functionality
124+
47125
### 1.1.2
48126

49127
* Implemented `\spaf\simputils\basic\with` functionality of a transactional style like
@@ -137,13 +215,14 @@ so documentation will come after that in the very nearest time. My apologies.
137215

138216
Minimal PHP version: **8.0**
139217

140-
Current framework version: **1.1.2**
218+
Current framework version: **1.1.3**
141219
```shell
142220
composer require spaf/simputils "^1"
143221
```
144222

145223
Keep in mind that the library development suppose to follow the semantic versioning,
146-
so the functionality within the same major version - should be backward-compatible.
224+
so the functionality within the same major version - should be backward-compatible (Except
225+
cases of bugs and issues).
147226

148227
More about semantic versioning: [Semantic Versioning Explanation](https://semver.org).
149228

phpcs.xml

Lines changed: 0 additions & 130 deletions
This file was deleted.

src/PHP.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use spaf\simputils\exceptions\RedefWrongReference;
1919
use spaf\simputils\exceptions\SerializationProblem;
2020
use spaf\simputils\exceptions\UnBoxable;
21+
use spaf\simputils\generic\BasicExecEnvHandler;
2122
use spaf\simputils\generic\BasicInitConfig;
2223
use spaf\simputils\generic\BasicIP;
2324
use spaf\simputils\generic\SimpleObject;
@@ -112,7 +113,7 @@ public static function frameworkDir() {
112113
*/
113114
public static function simpUtilsVersion(): Version|string {
114115
$class = static::redef(Version::class);
115-
return new $class('1.1.2', 'SimpUtils');
116+
return new $class('1.1.3', 'SimpUtils');
116117
}
117118

118119
/**
@@ -178,6 +179,10 @@ public static function init(null|array|Box|BasicInitConfig $args = null): BasicI
178179
// $config->___setup($args ?? []);
179180
static::metaMagicSpell($config, 'setup', $args ?? []);
180181

182+
if (empty($config->ee)) {
183+
$config->ee = BasicExecEnvHandler::EE_UNKNOWN;
184+
}
185+
181186
// TODO Implement code below into config through Properties
182187
if (!is_dir($config->code_root)) {
183188
$config->code_root = dirname($config->code_root);
@@ -192,6 +197,7 @@ public static function init(null|array|Box|BasicInitConfig $args = null): BasicI
192197
} else {
193198
// TODO Exception here?
194199
}
200+
195201
return $config;
196202
}
197203

@@ -618,7 +624,7 @@ public static function isArrayCompatible(mixed $var): bool {
618624
* @see \print_r()
619625
* @return void
620626
*/
621-
public static function pd(mixed ...$args) {
627+
static function pd(mixed ...$args) {
622628
$callback = CodeBlocksCacheIndex::getRedefinition(InitConfig::REDEF_PD);
623629
if ($callback && $callback !== InitConfig::REDEF_PD) {
624630
$res = (bool) $callback(...$args);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace spaf\simputils\components\execenvs;
4+
5+
use spaf\simputils\generic\SimpleObject;
6+
use spaf\simputils\interfaces\ExecEnvHandlerInterface;
7+
use spaf\simputils\Str;
8+
9+
/**
10+
* This is just an example of the custom Exec-Env handler.
11+
* It will return true or false that is specified from `$what_to_return`
12+
* field. Might be in rare cases useful for debugging.
13+
*
14+
*/
15+
class DummyExecEnvHandler extends SimpleObject implements ExecEnvHandlerInterface {
16+
17+
const EE_DEFAULT_NAME = 'dummy-exec-env';
18+
19+
public function __construct(
20+
public bool $what_to_return = true,
21+
public string $ee_name = self::EE_DEFAULT_NAME,
22+
public bool $include_signature = true,
23+
) {}
24+
25+
public function is(string $val): bool {
26+
return $this->what_to_return;
27+
}
28+
29+
public function __toString(): string {
30+
$res = Str::from($this->what_to_return);
31+
if ($this->include_signature) {
32+
return "{$this->ee_name}#{$res}";
33+
}
34+
35+
return "{$this->ee_name}";
36+
}
37+
38+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace spaf\simputils\exceptions;
4+
5+
use Exception;
6+
7+
class ExecEnvException extends Exception {
8+
9+
}

0 commit comments

Comments
 (0)