PHPackages                             ahamed/jsphp - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. ahamed/jsphp

ActiveLibrary[Testing &amp; Quality](/categories/testing)

ahamed/jsphp
============

A php library for implementing Array, Object, String methods in JavaScript way.

v0.6(2y ago)33502↓85.7%4[1 PRs](https://github.com/ahamed/JsPhp/pulls)1MITPHPPHP ^7.4|^8.0CI failing

Since Jul 18Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/ahamed/JsPhp)[ Packagist](https://packagist.org/packages/ahamed/jsphp)[ RSS](/packages/ahamed-jsphp/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (6)Dependencies (2)Versions (10)Used By (1)

[![BannerWithImageAndText](https://user-images.githubusercontent.com/5783354/87884417-03402d80-ca30-11ea-8fdc-5df12ca0e0aa.png)](https://user-images.githubusercontent.com/5783354/87884417-03402d80-ca30-11ea-8fdc-5df12ca0e0aa.png)

[![Packagist PHP Version Support](https://camo.githubusercontent.com/116258afed32a845fb6cd73ed6b8a8c07f998a496d55546e71c9f8606db1fb2c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b26636f6c6f723d346563343238)](https://camo.githubusercontent.com/116258afed32a845fb6cd73ed6b8a8c07f998a496d55546e71c9f8606db1fb2c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b26636f6c6f723d346563343238) [![GitHub](https://camo.githubusercontent.com/4873ae4c5ab5da07c892466323118f459d23c8caaa76bc0be327b956ca918f80/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b26636f6c6f723d346663353239)](https://camo.githubusercontent.com/4873ae4c5ab5da07c892466323118f459d23c8caaa76bc0be327b956ca918f80/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b26636f6c6f723d346663353239) [![GitHub Workflow Status (branch)](https://camo.githubusercontent.com/317afcd822437d284ac1d7274270ce8d9fa70e625c84a8497ed15a679b051090/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6168616d65642f4a735068702f504850253230436f6d706f7365722f6d61737465723f6c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/317afcd822437d284ac1d7274270ce8d9fa70e625c84a8497ed15a679b051090/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6168616d65642f4a735068702f504850253230436f6d706f7365722f6d61737465723f6c6162656c436f6c6f723d626c61636b) [![GitHub issues](https://camo.githubusercontent.com/6f31fe9d95217597dc5ac8bca1a35f2c1e364929a432f09f746a81a576f7d510/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6168616d65642f4a735068703f636f6c6f723d633530613136266c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/6f31fe9d95217597dc5ac8bca1a35f2c1e364929a432f09f746a81a576f7d510/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6168616d65642f4a735068703f636f6c6f723d633530613136266c6162656c436f6c6f723d626c61636b) [![GitHub closed issues](https://camo.githubusercontent.com/5fb9dd15d373f46c37f4001ebae982e9015ef79b2b3706a284ab56b22e25563d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d636c6f7365642f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/5fb9dd15d373f46c37f4001ebae982e9015ef79b2b3706a284ab56b22e25563d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d636c6f7365642f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b) [![GitHub pull requests](https://camo.githubusercontent.com/be4decaa7158f6e0e77ea2934769545c9f388f15899c7973ed5992ee61e25eab/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f6168616d65642f4a735068703f636f6c6f723d633530613136266c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/be4decaa7158f6e0e77ea2934769545c9f388f15899c7973ed5992ee61e25eab/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f6168616d65642f4a735068703f636f6c6f723d633530613136266c6162656c436f6c6f723d626c61636b) [![GitHub closed pull requests](https://camo.githubusercontent.com/6c486dce6468f90a0bcf084291805e2c746891ca364d1dc7f214f67f598c6da7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722d636c6f7365642f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/6c486dce6468f90a0bcf084291805e2c746891ca364d1dc7f214f67f598c6da7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722d636c6f7365642f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b) [![GitHub language count](https://camo.githubusercontent.com/35e07ca238dd893ca49840fea9f7afe8e5dc303dfdc4cf3b718ec29986f071fe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f756e742f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/35e07ca238dd893ca49840fea9f7afe8e5dc303dfdc4cf3b718ec29986f071fe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f756e742f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b) [![GitHub top language](https://camo.githubusercontent.com/b98042cc2490a7ddb3d22c8f5f58941f535931ae689671df20fba3baf82b7710/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f746f702f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/b98042cc2490a7ddb3d22c8f5f58941f535931ae689671df20fba3baf82b7710/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f746f702f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b) [![GitHub repo size](https://camo.githubusercontent.com/729d50f62f9390693b01635672d458b537c2fc4f5f002caa34b33689bc08073e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/729d50f62f9390693b01635672d458b537c2fc4f5f002caa34b33689bc08073e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b) [![GitHub All Releases](https://camo.githubusercontent.com/03d22e3b6e46dc2efe27e885ae5c1d8f064f5e0ad68393c878db3eb12a3343ea/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f6168616d65642f4a735068702f746f74616c3f6c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/03d22e3b6e46dc2efe27e885ae5c1d8f064f5e0ad68393c878db3eb12a3343ea/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f6168616d65642f4a735068702f746f74616c3f6c6162656c436f6c6f723d626c61636b) [![GitHub contributors](https://camo.githubusercontent.com/cc9b9e529d49caaf850717745d09550263207c0a165ae99065db8897cda8a373/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/cc9b9e529d49caaf850717745d09550263207c0a165ae99065db8897cda8a373/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b) [![GitHub last commit](https://camo.githubusercontent.com/350a4ba55d520df0edf73f877b577fc8c82fcc599a71a1184dda4dcd476224ab/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/350a4ba55d520df0edf73f877b577fc8c82fcc599a71a1184dda4dcd476224ab/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b) [![GitHub Release Date](https://camo.githubusercontent.com/2ef748f687facd311a757dec5d9ae10a25340c9a498ab4eca32e5d08dd397df2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652d646174652f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/2ef748f687facd311a757dec5d9ae10a25340c9a498ab4eca32e5d08dd397df2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652d646174652f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b) [![GitHub release (latest by date including pre-releases)](https://camo.githubusercontent.com/d3368283f0753548e5fed5bf8616e9259a66a9e6d3dd8cd155e3771181a2192a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6168616d65642f4a735068703f696e636c7564655f70726572656c6561736573266c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/d3368283f0753548e5fed5bf8616e9259a66a9e6d3dd8cd155e3771181a2192a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6168616d65642f4a735068703f696e636c7564655f70726572656c6561736573266c6162656c436f6c6f723d626c61636b) [![GitHub tag (latest by date)](https://camo.githubusercontent.com/f15cd060dc3f56c8601145af017df421d006ea335d9688f72696a937961f798a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/f15cd060dc3f56c8601145af017df421d006ea335d9688f72696a937961f798a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b)

[![Packagist Version](https://camo.githubusercontent.com/2ffdbc08a669eda4266a1156da6a9b47ec01cb7d7ca132aea9938086f0ac83a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/2ffdbc08a669eda4266a1156da6a9b47ec01cb7d7ca132aea9938086f0ac83a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b) [![Packagist Downloads](https://camo.githubusercontent.com/257242be652bd1706e448c415b2e1e6bbf273c0e65c0d679779e70649c8602b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6168616d65642f4a735068703f636f6c6f723d663138643162266c6162656c3d5061636b6167697374253230446f776e6c6f616473266c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/257242be652bd1706e448c415b2e1e6bbf273c0e65c0d679779e70649c8602b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6168616d65642f4a735068703f636f6c6f723d663138643162266c6162656c3d5061636b6167697374253230446f776e6c6f616473266c6162656c436f6c6f723d626c61636b) [![Packagist Stars](https://camo.githubusercontent.com/3103a3eb84b86b355869354f33ecd0243a2c4ad877ff7af3e58b83c66d6e7793/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b)](https://camo.githubusercontent.com/3103a3eb84b86b355869354f33ecd0243a2c4ad877ff7af3e58b83c66d6e7793/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6168616d65642f4a735068703f6c6162656c436f6c6f723d626c61636b)

### Why this library?

[](#why-this-library)

While using ***php*** **Array** methods it feels troublesome because of their unstructured patterns.

For example, you are using the `array_map` and the `array_filter` methods of *php*. At the time of using, you may notice that for the `array_map` method, the `$callback` comes as the first parameter of the method, then the `$array` but for the `array_filter` method, the `$array` comes first then the `$callback`. And this mixed structure exists everywhere.

Then I've discovered that the **JavaScript** uses a good pattern for these cases and I am also a big fan of JavaScript. That's why I've decided to build this library. I can say that the JavaScript lovers can get the pure feelings of JavaScript by using this and the JavaScript non-lovers also get the advantage of the good structure of **array** manipulations.

### Future Journey

[](#future-journey)

Currently I've covered only the `array` methods. In near future I will add the `object` and `string` methods.

### Installation

[](#installation)

`composer` is needed for installing the package. If you have composer installed then run the command.

```
composer require ahamed/jsphp
```

### Usage

[](#usage)

After successful installation, include the library into your project.

```
require_once __DIR__ . '/vendor/autoload.php';

use Ahamed\JsPhp\JsArray;

$data = [1, 2, 3, 4, 5];
$array = new JsArray($data);

$square = $array->map(
    function ($item) {
        return $item * $item;
    }
);

print_r($square);
```

Documentation
=============

[](#documentation)

> For writing this documentation I've followed the [MDN](https://developer.mozilla.org/en-US/) a lot. Thanks to **MDN**, this site helps me to learn a lot of JS.

Follow the wiki pages for the details documentation.

- [JsArray](https://github.com/ahamed/JsPhp/wiki/JsArray)
- [JsObject](https://github.com/ahamed/JsPhp/wiki/JsObject)

### Testing

[](#testing)

You can run `PHPUnit` testing and `PHP_CodeSniffer`.

- For running unit test ```
    composer run-script test
    ```
- For running phpcs test ```
    composer run-script phpcs
    ```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance53

Moderate activity, may be stable

Popularity25

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity56

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 ~222 days

Recently: every ~277 days

Total

6

Last Release

1017d ago

PHP version history (3 changes)v0.1PHP ^7.0

v0.3PHP ^7.0|^8.0

v0.6PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/03f18fd809f033b90d45f6dde7a4855a6633d7ec9a49effa8b652419301c33b9?d=identicon)[sajeeb07ahamed](/maintainers/sajeeb07ahamed)

---

Top Contributors

[![ahamed](https://avatars.githubusercontent.com/u/5783354?v=4)](https://github.com/ahamed "ahamed (86 commits)")

---

Tags

composercomposer-packagehacktoberfesthacktoberfest2021phpphpcsphpunitunit-testingutility-library

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/ahamed-jsphp/health.svg)

```
[![Health](https://phpackages.com/badges/ahamed-jsphp/health.svg)](https://phpackages.com/packages/ahamed-jsphp)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)

PHPackages © 2026

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