PHPackages                             cancio-labs/php-stack - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. cancio-labs/php-stack

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cancio-labs/php-stack
=====================

Interface and an array-based implementation of the LIFO Stack data structure.

v1.2.1(1y ago)07GPL-3.0-or-laterPHPPHP ^8.1

Since Feb 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/canciolabs/php-stack)[ Packagist](https://packagist.org/packages/cancio-labs/php-stack)[ RSS](/packages/cancio-labs-php-stack/feed)WikiDiscussions 1.2 Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (8)Used By (0)

CancioLabs / DS / PHP-Stack
===========================

[](#canciolabs--ds--php-stack)

This tiny package contains an interface and an array-based implementation of the LIFO Stack data structure.

Interface
---------

[](#interface)

MethodDescriptionpushAdds a new element to the top of the stack.popRemoves and return the top element of the stack.topReturns the top element of the stack.isEmptyTests whether the stack is empty.clearRemoves all elements from the stack.countReturns the number of elements of the stack.toArrayTransforms the stack into an array.How to use it
-------------

[](#how-to-use-it)

```
$stack = new Stack(['A', 'B']);

$stack->push('C');
$stack->push('D');

$stack->isEmpty(); // returns false
$stack->count(); // returns 4

$stack->top(); // output 'D'
$stack->pop(); // returns 'D'

$array = $stack->toArray(); // return ['A', 'B', 'C']

foreach ($stack as $element) {
    // i=0: $element = 'C'
    // i=1: $element = 'B'
    // i=2: $element = 'A'
}

$stack->isEmpty(); // returns true

```

Tests and Coverage
------------------

[](#tests-and-coverage)

All tests are passing with no warnings and code coverage is 100%.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance42

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~55 days

Recently: every ~83 days

Total

7

Last Release

477d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/65afdceff66eba436390f0041cd197dfef88b72f96a719e11477c315eb797ebb?d=identicon)[nilosoares](/maintainers/nilosoares)

---

Top Contributors

[![nilosoares](https://avatars.githubusercontent.com/u/7283619?v=4)](https://github.com/nilosoares "nilosoares (1 commits)")

---

Tags

data-structuresphpstackstackdsdata structure

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cancio-labs-php-stack/health.svg)

```
[![Health](https://phpackages.com/badges/cancio-labs-php-stack/health.svg)](https://phpackages.com/packages/cancio-labs-php-stack)
```

###  Alternatives

[php-ds/php-ds

Specialized data structures as alternatives to the PHP array

4108.8M134](/packages/php-ds-php-ds)[loophp/phptree

An implementation of tree data structure

981.8M2](/packages/loophp-phptree)[aldemeery/onion

A layering mechanism for PHP applications.

5810.7k2](/packages/aldemeery-onion)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
