Skip to content

Commit

Permalink
php-simputils-109 Release of 1.1.3 (#110)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
PandaHugMonster authored Jul 31, 2022
1 parent 8db25d8 commit 32be00e
Show file tree
Hide file tree
Showing 30 changed files with 1,115 additions and 149 deletions.
83 changes: 81 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,86 @@ I will be really happy hearing from you.

----

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

## Changelog

### 1.1.3

* Implemented method `\spaf\simputils\models\Box::batch()` that allows to easily export items
of specified keys to the local variable scope
* Implemented methods `setFromData()` and meta-magic methods `___serialize()` and
`___deserialize()` to fix PHP native serialization/deserialization for the
following classes:
* `\spaf\simputils\models\Version`
* `\spaf\simputils\models\UrlObject`
* `\spaf\simputils\models\Time`
* `\spaf\simputils\models\L10n`
* `\spaf\simputils\models\IPv4Range`
* `\spaf\simputils\models\IPv4`
* `\spaf\simputils\models\File`
* `\spaf\simputils\models\Dir`
* `\spaf\simputils\models\DateTimeZone`
* `\spaf\simputils\models\DateTime`
* `\spaf\simputils\models\DatePeriod`
* `\spaf\simputils\models\DateInterval`
* `\spaf\simputils\models\Date`
* `\spaf\simputils\models\DataUnit`
* `\spaf\simputils\models\BigNumber`
* Code Sniffer is removed from the project (got really annoyed, and it does not work correctly)
* `\spaf\simputils\models\Time` and `\spaf\simputils\models\Date` have been refactored a bit.
The caching mechanics has been fixed.
* Additionally have been added the properties for `\spaf\simputils\models\Date`
and `\spaf\simputils\models\Time` from the target `DateTime` object
* `\spaf\simputils\models\Date` and `\spaf\simputils\models\Time` result of `for_system`
now returns the whole DateTime string value of UTC, not only the date or time component.
* Implemented `\spaf\simputils\generic\BasicExecEnvHandler` Execution-Environment (aka stages),
besides that implemented `\spaf\simputils\generic\BasicInitConfig::@$ee` property that
automatically will be assigned during `PHP::init()`, the object or params could be
adjusted in the incoming config, example:
```php
$ic = PHP::init([
'l10n' => 'AT',
// 'ee' => new DummyExecEnvHandler(false, ee_name: 'TOO'),
'ee' => [
'ee' => 'test3-local',
'is_hierarchical' => true,
'permitted_values' => [
'test1',
'test2',
'test3',
'test4',
]
]
]);
pd("{$ic->ee}", Boolean::to($ic->ee->is('test4-local')));
```
For now not much of documentation is provided, but you always can define your own
implementation of the class like `\spaf\simputils\components\execenvs\DummyExecEnvHandler`
to handle your Exec-Env/stages implementation! More documentation and example will follow.
* Additionally implemented `\spaf\simputils\components\execenvs\DummyExecEnvHandler`
which is a dummy handler that just returns the predefined value. Should not be used
on production.
* Implemented `\spaf\simputils\exceptions\ExecEnvException` exception for Exec-Env cases
* Implemented `\spaf\simputils\models\Box::popFromStart()` and
`\spaf\simputils\models\Box::popFromEnd()` methods to get value from the box, return
and remove it from the box.
* Implemented tests for:
* Exec-Env
* Box batch functionality

### 1.1.2

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

Minimal PHP version: **8.0**

Current framework version: **1.1.2**
Current framework version: **1.1.3**
```shell
composer require spaf/simputils "^1"
```

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

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

Expand Down
130 changes: 0 additions & 130 deletions phpcs.xml

This file was deleted.

10 changes: 8 additions & 2 deletions src/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use spaf\simputils\exceptions\RedefWrongReference;
use spaf\simputils\exceptions\SerializationProblem;
use spaf\simputils\exceptions\UnBoxable;
use spaf\simputils\generic\BasicExecEnvHandler;
use spaf\simputils\generic\BasicInitConfig;
use spaf\simputils\generic\BasicIP;
use spaf\simputils\generic\SimpleObject;
Expand Down Expand Up @@ -112,7 +113,7 @@ public static function frameworkDir() {
*/
public static function simpUtilsVersion(): Version|string {
$class = static::redef(Version::class);
return new $class('1.1.2', 'SimpUtils');
return new $class('1.1.3', 'SimpUtils');
}

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

if (empty($config->ee)) {
$config->ee = BasicExecEnvHandler::EE_UNKNOWN;
}

// TODO Implement code below into config through Properties
if (!is_dir($config->code_root)) {
$config->code_root = dirname($config->code_root);
Expand All @@ -192,6 +197,7 @@ public static function init(null|array|Box|BasicInitConfig $args = null): BasicI
} else {
// TODO Exception here?
}

return $config;
}

Expand Down Expand Up @@ -618,7 +624,7 @@ public static function isArrayCompatible(mixed $var): bool {
* @see \print_r()
* @return void
*/
public static function pd(mixed ...$args) {
static function pd(mixed ...$args) {
$callback = CodeBlocksCacheIndex::getRedefinition(InitConfig::REDEF_PD);
if ($callback && $callback !== InitConfig::REDEF_PD) {
$res = (bool) $callback(...$args);
Expand Down
38 changes: 38 additions & 0 deletions src/components/execenvs/DummyExecEnvHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace spaf\simputils\components\execenvs;

use spaf\simputils\generic\SimpleObject;
use spaf\simputils\interfaces\ExecEnvHandlerInterface;
use spaf\simputils\Str;

/**
* This is just an example of the custom Exec-Env handler.
* It will return true or false that is specified from `$what_to_return`
* field. Might be in rare cases useful for debugging.
*
*/
class DummyExecEnvHandler extends SimpleObject implements ExecEnvHandlerInterface {

const EE_DEFAULT_NAME = 'dummy-exec-env';

public function __construct(
public bool $what_to_return = true,
public string $ee_name = self::EE_DEFAULT_NAME,
public bool $include_signature = true,
) {}

public function is(string $val): bool {
return $this->what_to_return;
}

public function __toString(): string {
$res = Str::from($this->what_to_return);
if ($this->include_signature) {
return "{$this->ee_name}#{$res}";
}

return "{$this->ee_name}";
}

}
9 changes: 9 additions & 0 deletions src/exceptions/ExecEnvException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace spaf\simputils\exceptions;

use Exception;

class ExecEnvException extends Exception {

}
Loading

0 comments on commit 32be00e

Please sign in to comment.