Skip to content

Commit 6686425

Browse files
committed
Refactored and restructured core FireHub data structures and behaviors.
**Detailed Description:** 1. **Removal of Legacy Classes and Traits:** - Deleted redundant or outdated classes (`ArrayCollection`, `Transformable`, `Collection`, etc.) and traits (`Convertable`, `Enumerable`, `Shared`), previously used for array-backed and enumerable data structures. - Removed unit tests (`ArrayCollectionTest.php`) tied to removed functionality. 2. **Improved Contract Hierarchy:** - Introduced new core principles to enforce modularity and extensibility: - `Behavior\Countable`: Abstracted and decoupled element counting into a specific contract. - `Behavior\Enumerable`: Redesigned for higher-level traversal operations and composability. - Added `Storage` as a universal base for managing data persistence/access with flexible memory models. - Defined `Linear` as a foundational interface for sequential-access structures and standardized traversal patterns. 3. **New Linear `Sequence` Module:** - Created `linear\firehub\Sequence`, isolating linear-sequential structures post refactor. - Emphasized predictable access while aligning with modern scalability goals. 4. **Better Autoloading Support in Enterprise Environment:** - Enhanced `Core-Enterprise/src/public/index.php` autoloader: - Added `classmap` and `compiled classmap` integration for optimized, layered dependency resolution. - Introduced handlers for namespace isolation and dependency-deduplication efficiency. **Key User Benefits:** - Simplified, composable behaviors for all FireHub data structures (`Countable`, `Enumerable`, etc.). - Unified and cleaner contract hierarchy streamlining developer onboarding. - Modular, future-proof linear processing APIs catering to high-demand applications.
1 parent 5922510 commit 6686425

19 files changed

Lines changed: 296 additions & 944 deletions

dist/core.min.phar

-3.04 KB
Binary file not shown.

dist/core.phar

-15.2 KB
Binary file not shown.

src/support/autoload/classmap.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,12 @@
7878
\FireHub\Core\Support\Bootstrap\Bootloader\RegisterHelpers::class => __DIR__.'/../../support/bootstrap/bootloader/firehub.RegisterHelpers.php',
7979
\FireHub\Core\Support\Bootstrap\FireHubConfigurator::class => __DIR__.'/../../support/bootstrap/firehub.FireHubConfigurator.php',
8080
\FireHub\Core\Support\Contracts\DataStructure::class => __DIR__.'/../../support/contracts/firehub.DataStructure.php',
81-
\FireHub\Core\Support\DataStructure\Abstract\ArrayCollection::class => __DIR__.'/../../support/datastructure/abstract/firehub.ArrayCollection.php',
82-
\FireHub\Core\Support\DataStructure\ArrayCollection::class => __DIR__.'/../../support/datastructure/firehub.ArrayCollection.php',
83-
\FireHub\Core\Support\DataStructure\Contracts\Capability\Transformable::class => __DIR__.'/../../support/datastructure/contracts/capability/firehub.Transformable.php',
84-
\FireHub\Core\Support\DataStructure\Contracts\Collection::class => __DIR__.'/../../support/datastructure/contracts/firehub.Collection.php',
85-
\FireHub\Core\Support\DataStructure\Traits\Convertable::class => __DIR__.'/../../support/datastructure/traits/firehub.Convertable.php',
86-
\FireHub\Core\Support\DataStructure\Traits\Enumerable::class => __DIR__.'/../../support/datastructure/traits/firehub.Enumerable.php',
87-
\FireHub\Core\Support\DataStructure\Traits\Shared::class => __DIR__.'/../../support/datastructure/traits/firehub.Shared.php',
81+
\FireHub\Core\Support\DataStructure\Behavior\Countable::class => __DIR__.'/../../support/datastructure/behavior/firehub.Countable.php',
82+
\FireHub\Core\Support\DataStructure\Behavior\Enumerable::class => __DIR__.'/../../support/datastructure/behavior/firehub.Enumerable.php',
83+
\FireHub\Core\Support\DataStructure\Linear::class => __DIR__.'/../../support/datastructure/firehub.Linear.php',
84+
\FireHub\Core\Support\DataStructure\Linear\Sequence::class => __DIR__.'/../../support/datastructure/linear/firehub.Sequence.php',
85+
\FireHub\Core\Support\DataStructure\Storage::class => __DIR__.'/../../support/datastructure/firehub.Storage.php',
86+
\FireHub\Core\Support\DataStructure\Storage\ArrStorage::class => __DIR__.'/../../support/datastructure/storage/firehub.ArrStorage.php',
8887
\FireHub\Core\Support\LowLevel::class => __DIR__.'/../../support/firehub.LowLevel.php',
8988
\FireHub\Core\Support\LowLevel\Arr::class => __DIR__.'/../../support/lowlevel/firehub.Arr.php',
9089
\FireHub\Core\Support\LowLevel\CharMB::class => __DIR__.'/../../support/lowlevel/firehub.CharMB.php',

src/support/autoload/loader/firehub.CompiledClassmap.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -244,32 +244,28 @@ public function __invoke (string $class):void {
244244
require __DIR__.'/../../../support/contracts/firehub.DataStructure.php';
245245
return;
246246

247-
case \FireHub\Core\Support\DataStructure\Abstract\ArrayCollection::class:
248-
require __DIR__.'/../../../support/datastructure/abstract/firehub.ArrayCollection.php';
247+
case \FireHub\Core\Support\DataStructure\Behavior\Countable::class:
248+
require __DIR__.'/../../../support/datastructure/behavior/firehub.Countable.php';
249249
return;
250250

251-
case \FireHub\Core\Support\DataStructure\ArrayCollection::class:
252-
require __DIR__.'/../../../support/datastructure/firehub.ArrayCollection.php';
251+
case \FireHub\Core\Support\DataStructure\Behavior\Enumerable::class:
252+
require __DIR__.'/../../../support/datastructure/behavior/firehub.Enumerable.php';
253253
return;
254254

255-
case \FireHub\Core\Support\DataStructure\Contracts\Capability\Transformable::class:
256-
require __DIR__.'/../../../support/datastructure/contracts/capability/firehub.Transformable.php';
255+
case \FireHub\Core\Support\DataStructure\Linear::class:
256+
require __DIR__.'/../../../support/datastructure/firehub.Linear.php';
257257
return;
258258

259-
case \FireHub\Core\Support\DataStructure\Contracts\Collection::class:
260-
require __DIR__.'/../../../support/datastructure/contracts/firehub.Collection.php';
259+
case \FireHub\Core\Support\DataStructure\Linear\Sequence::class:
260+
require __DIR__.'/../../../support/datastructure/linear/firehub.Sequence.php';
261261
return;
262262

263-
case \FireHub\Core\Support\DataStructure\Traits\Convertable::class:
264-
require __DIR__.'/../../../support/datastructure/traits/firehub.Convertable.php';
263+
case \FireHub\Core\Support\DataStructure\Storage::class:
264+
require __DIR__.'/../../../support/datastructure/firehub.Storage.php';
265265
return;
266266

267-
case \FireHub\Core\Support\DataStructure\Traits\Enumerable::class:
268-
require __DIR__.'/../../../support/datastructure/traits/firehub.Enumerable.php';
269-
return;
270-
271-
case \FireHub\Core\Support\DataStructure\Traits\Shared::class:
272-
require __DIR__.'/../../../support/datastructure/traits/firehub.Shared.php';
267+
case \FireHub\Core\Support\DataStructure\Storage\ArrStorage::class:
268+
require __DIR__.'/../../../support/datastructure/storage/firehub.ArrStorage.php';
273269
return;
274270

275271
case \FireHub\Core\Support\LowLevel::class:

src/support/contracts/firehub.DataStructure.php

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@
1313

1414
namespace FireHub\Core\Support\Contracts;
1515

16-
use FireHub\Core\Shared\Contracts\ {
17-
Countable, IteratorAggregate
18-
};
19-
20-
use const FireHub\Core\Shared\Constants\Number\MAX;
21-
2216
/**
23-
* ### Data structures Contract
17+
* ### Data structure Contract
2418
*
2519
* Defines a generic, type-safe contract for all high-level data structures in FireHub.<br>
2620
* Supports iteration, array conversion, serialization, and common utility operations, ensuring consistency across
@@ -29,29 +23,5 @@
2923
*
3024
* @template TKey
3125
* @template TValue
32-
*
33-
* @extends \FireHub\Core\Shared\Contracts\IteratorAggregate<TKey, TValue>
3426
*/
35-
interface DataStructure extends Countable, IteratorAggregate {
36-
37-
/**
38-
* ### Call a user-generated function on each item in the data structure
39-
* @since 1.0.0
40-
*
41-
* @uses \FireHub\Core\Shared\Constants\Number\MAX As default limit.
42-
* @uses \FireHub\Core\Shared\Enums\ControlFlow\Signal::BREAK As signal.
43-
*
44-
* @param callable(TValue, TKey):(\FireHub\Core\Shared\Enums\ControlFlow\Signal::BREAK|\FireHub\Core\Shared\Enums\ControlFlow\Signal::CONTINUE) $callback <p>
45-
* Function to call on each item in a data structure.<br>
46-
* Return `Signal::BREAK` to stop iteration early.
47-
* Return `Signal::CONTINUE` to continue iteration.
48-
* </p>
49-
* @param positive-int $limit [optional] <p>
50-
* Maximum number of elements that is allowed to be iterated.
51-
* </p>
52-
*
53-
* @return static This data structure.
54-
*/
55-
public function each (callable $callback, int $limit = MAX):static;
56-
57-
}
27+
interface DataStructure {}

src/support/datastructure/abstract/firehub.ArrayCollection.php

Lines changed: 0 additions & 191 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php declare(strict_types = 1);
2+
3+
/**
4+
* This file is part of the FireHub Project ecosystem
5+
*
6+
* @author Danijel Galić <danijel.galic@outlook.com>
7+
* @copyright 2026 The FireHub Project - All rights reserved
8+
* @license https://opensource.org/license/Apache-2-0 Apache License, Version 2.0
9+
*
10+
* @php-version 7.0
11+
* @package Core\Support
12+
*/
13+
14+
namespace FireHub\Core\Support\DataStructure\Behavior;
15+
16+
use FireHub\Core\Shared\Contracts\Countable as CountableContract;
17+
18+
/**
19+
* ### Countable Behavior Contract
20+
*
21+
* Defines the ability to determine the number of elements within a structure. Ensures that the structure can provide
22+
* a consistent and reliable size or element count at any given time.
23+
* @since 1.0.0
24+
*/
25+
interface Countable extends CountableContract {}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php declare(strict_types = 1);
2+
3+
/**
4+
* This file is part of the FireHub Project ecosystem
5+
*
6+
* @author Danijel Galić <danijel.galic@outlook.com>
7+
* @copyright 2026 The FireHub Project - All rights reserved
8+
* @license https://opensource.org/license/Apache-2-0 Apache License, Version 2.0
9+
*
10+
* @php-version 7.0
11+
* @package Core\Support
12+
*/
13+
14+
namespace FireHub\Core\Support\DataStructure\Behavior;
15+
16+
use FireHub\Core\Shared\Contracts\IteratorAggregate;
17+
18+
/**
19+
* ### Enumerable Behavior Contract
20+
*
21+
* Defines the ability to iterate over all elements in a structure. Provides higher-level traversal operations such
22+
* as mapping, filtering, and transformation, typically built on top of a traversal mechanism.
23+
* @since 1.0.0
24+
*
25+
* @template TKey
26+
* @template TValue
27+
*
28+
* @extends \FireHub\Core\Shared\Contracts\IteratorAggregate<TKey, TValue>
29+
*/
30+
interface Enumerable extends IteratorAggregate {}

0 commit comments

Comments
 (0)