PHPackages                             setnemo/asterisk-notation - 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. setnemo/asterisk-notation

ActiveLibrary

setnemo/asterisk-notation
=========================

Asterisk notation for array access in PHP

0.1.2(4y ago)151MITPHPPHP ^7.4|~8.0.0

Since Sep 7Pushed 4y ago1 watchersCompare

[ Source](https://github.com/setnemo/asterisk-notation)[ Packagist](https://packagist.org/packages/setnemo/asterisk-notation)[ RSS](/packages/setnemo-asterisk-notation/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (5)Used By (0)

PHP Asterisk Notation
=====================

[](#php-asterisk-notation)

[![Latest Stable Version](https://camo.githubusercontent.com/967ab16db9ebf7e345bc182939ce28127105084551defc2c8cadb126d1bc8d58/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f7365746e656d6f2f617374657269736b2d6e6f746174696f6e)](https://github.com/setnemo/asterisk-notation/releases)

[![Github actions Build](https://camo.githubusercontent.com/d506916132d2cb98b47c069fcaa74c1eddb70aa3745a7c8eb126c8f0e4e22377/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7365746e656d6f2f617374657269736b2d6e6f746174696f6e2f5465737473)](//github.com/setnemo/asterisk-notation/actions)

[![SonarCloud Coverage](https://camo.githubusercontent.com/0f920984a15bb0f770d102fc3c67d3ae3bc32b39314a463b87d369612797d6f8/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d7365746e656d6f5f617374657269736b2d6e6f746174696f6e266d65747269633d636f766572616765)](https://sonarcloud.io/component_measures/metric/coverage/list?id=setnemo_asterisk-notation)[![SonarCloud Reliability rating](https://camo.githubusercontent.com/79635a31cdd4b540ad2ff0353346b85010081f24a277ea7338e8a6bb398718e8/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d7365746e656d6f5f617374657269736b2d6e6f746174696f6e266d65747269633d72656c696162696c6974795f726174696e67)](https://sonarcloud.io/component_measures/metric/reliability_rating/list?id=setnemo_asterisk-notation)[![SonarCloud Security rating](https://camo.githubusercontent.com/e9bf3f0e9205ae1a2a04a4d4828bbdef61a696b45ac1837754a2d1c5760e47f6/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d7365746e656d6f5f617374657269736b2d6e6f746174696f6e266d65747269633d73656375726974795f726174696e67)](https://sonarcloud.io/component_measures/metric/security_rating/list?id=setnemo_asterisk-notation)[![SonarCloud Bugs](https://camo.githubusercontent.com/e89513136476a013281c4e5e51f80f1a040da970d92b0b93d3b7e49d7523f6c8/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d7365746e656d6f5f617374657269736b2d6e6f746174696f6e266d65747269633d62756773)](https://sonarcloud.io/component_measures/metric/bugs/list?id=setnemo_asterisk-notation)[![SonarCloud Code Smells](https://camo.githubusercontent.com/cc7d33c7aab1f72feb13b6fda4088bb5b03a548de8a792bbaf03d1e6e213740a/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d7365746e656d6f5f617374657269736b2d6e6f746174696f6e266d65747269633d636f64655f736d656c6c73)](https://sonarcloud.io/component_measures/metric/code_smells/list?id=setnemo_asterisk-notation)

[![Github License](https://camo.githubusercontent.com/eb7ee966daca5d91946e450e4f7e8874082c7cd409b06f8852aa58e598a02d30/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7365746e656d6f2f617374657269736b2d6e6f746174696f6e2e737667)](https://packagist.org/packages/setnemo/asterisk-notation)

Asterisk notation for array access in PHP. Update array access to the next level of usability.

Asterisk notation
-----------------

[](#asterisk-notation)

```
use Setnemo\Asterisk;

$items = new Asterisk([
    'Europe' => [
        'Ukraine' => [
            'capital' => 'Kyiv',
            'currency' => 'UAH'
        ],
        'Poland' => [
            'capital' => 'Warsaw',
            'currency' => 'PLN'
        ],

    ],
    'Africa' => [
        'South Africa' => [
            'capital' => 'Capetown',
            'currency' => 'ZAR'
        ],
        'Nigeria' => [
            'capital' => 'Abuja',
            'currency' => 'NGN'
        ],
    ],
]);
$city = 'Kyiv';
$resultTrue = $items->has('*.*.capital', $city);
$resultFalse = $items->has('Africa.*.capital', $city);
if ($resultTrue === true && $resultFalse === false) {
    echo "Wow! It works correctly!";
}
```

Install
-------

[](#install)

Install the latest version using Composer:

```
composer require setnemo/asterisk-notation
```

Usage
-----

[](#usage)

Create a new \\Setnemo\\Asterisk object:

```
use Adbar\Dot;
use Setnemo\Asterisk;
$asterisk = new Asterisk;
$array = ['first_one' => ['second' => 'value'], 'first_two' => ['second' => 'value'],];
// With existing array
$asterisk = new Asterisk($array);
// With existing \Adbar\Dot
$dot = new Dot($array);
$asterisk = new Asterisk($dot);
// or existing Asterisk
$newAsterisk = new Asterisk($asterisk);
```

Methods
-------

[](#methods)

Asterisk has the following methods:

- [add()](#add)
- [all()](#all)
- [clear()](#clear)
- [count()](#count)
- [delete()](#delete)
- [flatten()](#flatten)
- [get()](#get)
- [has()](#has)
- [isEmpty()](#isempty)
- [merge()](#merge)
- [mergeRecursive()](#mergerecursive)
- [mergeRecursiveDistinct()](#mergerecursivedistinct)
- [pull()](#pull)
- [push()](#push)
- [replace()](#replace) // use Dot::replace(), **need write tests**, because used get(), set()
- [set()](#set)
- [setArray()](#setarray)
- [setReference()](#setreference)
- [toJson()](#tojson) // use Dot::toJson(), **need write tests**, because used get()

### add()

[](#add)

Using for adding element with asterisk in key

> Work like [Adbar\\Dot::add()](https://github.com/adbario/php-dot-notation#add)

### all()

[](#all)

> Work like [Adbar\\Dot::all()](https://github.com/adbario/php-dot-notation#all)

### clear()

[](#clear)

Deletes the contents of a given key (sets an empty array):

```
$asterisk->clear('department.*.write_rules');

// Equivalent vanilla PHP
$array['department']['project1']['write_rules'] = [];
$array['department']['project2']['write_rules'] = [];
$array['department']['projectN']['write_rules'] = [];
```

Multiple keys:

```
$asterisk->clear(['department.*.write_rules', 'department.*.read_rules']);
```

All the stored items:

```
$asterisk->clear();

// Equivalent vanilla PHP
$array = [];
```

> If key not contains \* (asterisk) - it works like [Adbar\\Dot::clear()](https://github.com/adbario/php-dot-notation#clear)

### count()

[](#count)

Returns the number of items in a given key:

```
$asterisk->count('user.siblings');
```

Items in the root of Dot object:

```
$asterisk->count();

// Or use count() function as Dot implements Countable
count($asterisk);
```

> If key not contains \* (asterisk) - it works like [Adbar\\Dot::count()](https://github.com/adbario/php-dot-notation#count)

### delete()

[](#delete)

Deletes the given key:

```
$asterisk->delete('*.name');

// ArrayAccess
unset($asterisk['user1.name']);
unset($asterisk['user2.name']);

// Equivalent vanilla PHP
unset($array['user1']['name']);
unset($array['user2']['name']);
```

Multiple keys:

```
$asterisk->delete([
    '*.name',
    '*.title'
]);
```

### flatten()

[](#flatten)

> It works like [Adbar\\Dot::flatten()](https://github.com/adbario/php-dot-notation#flatten)

### get()

[](#get)

Returns the value of a given key:

```
$result = $asterisk->get('*.name'));

// ArrayAccess
$result['user1.name'] = $asterisk['user1.name'];
$result['user2.name'] = $asterisk['user2.name'];

// Equivalent vanilla PHP
if (isset($array['user1']['name']) {
    $result['user1.name'] = $array['user1']['name'];
}
if (isset($array['user1']['name']) {
    $result['user2.name'] = $array['user2']['name'];
}
```

Returns a given default value, if the given key doesn't exist:

```
echo $asterisk->get('user.name', 'some default value');
```

> Default value not work with asterisk

### has()

[](#has)

Checks if a given key exists (returns boolean true or false):

```
$asterisk->has('user.name');

// ArrayAccess
isset($asterisk['user.name']);
```

Multiple keys:

```
$asterisk->has([
    'user.name',
    'page.title'
]);
```

With asterisk:

```
$asterisk = new \Setnemo\Asterisk(['1' => ['second' => 'value'],'2' => ['second' => 'value']]);
$asterisk->has('*.second'); // true
$asterisk = new \Setnemo\Asterisk(['1' => ['first' => ['test' => 42]],'2' => ['second' => 'value'],'3' => ['third' => ['value' => 42]]]);
$asterisk->has('*.*.value'); // true
$asterisk = new \Setnemo\Asterisk(['user1' => ['name' => 'John', 'job' => 'warrior'], 'user2' => ['name' => 'Robin', 'job' => 'archer']);
$asterisk->has('*.spouse'); // false
```

With asterisk and value:

```
$asterisk = new \Setnemo\Asterisk([]);
$asterisk->has('*', false); // false
$asterisk = new \Setnemo\Asterisk(['*' => ['second' => 'VALUE']]);
$asterisk->has('*.second', 'VALUE'); // true
$asterisk->has('*.second', 'value'); // false because lowercase
$asterisk = new \Setnemo\Asterisk(['*' => ['second' => 'value'], 0 => [0 => 0], 11 => 11]);
$asterisk->has('*.11', 11); // true
$asterisk = new \Setnemo\Asterisk(['1' => ['second' => 'value'],'2' => ['second' => '-']]);
$asterisk->has('*.second', 'value'); // false because 'second' => '-'
$asterisk = new \Setnemo\Asterisk(['1' => ['second' => 'value'],'2' => ['second' => 'value']]);
$asterisk->has('*.second', 'value'); // true
```

With asterisk and value (non-strict mode):

```
$asterisk = new \Setnemo\Asterisk([
'locations' => [
    'Europe' => [
        'Ukraine' => [
            'capital' => 'Kyiv',
            'currency' => 'UAH'
        ],
        'Poland' => [
            'capital' => 'Warsaw',
            'currency' => 'PLN'
        ],

    ],
    'Africa' => [
        'South Africa' => [
            'capital' => 'Capetown',
            'currency' => 'ZAR'
        ],
        'Nigeria' => [
            'capital' => 'Abuja',
            'currency' => 'NGN'
        ],
    ],
]]);
// third parameter is false for non-strict mode
$asterisk->has('locations.*.*.capital', 'Kyiv', false); // true
$asterisk->has('locations.*.*.currency', 'ZAR', false); // true
$asterisk->has('locations.Europe.*.currency', 'ZAR', false); // false
```

### isEmpty()

[](#isempty)

Checks if a given key is empty (returns boolean true or false):

```
$asterisk->isEmpty('user.name');

// ArrayAccess
empty($asterisk['user.name']);

// Equivalent vanilla PHP
empty($array['user']['name']);
```

Multiple keys:

```
$asterisk->isEmpty([
    'user.name',
    'page.title'
]);
```

Checks the whole Asterisk object:

```
$asterisk->isEmpty();
```

Also works with asterisk in key:

```
$asterisk = new \Setnemo\Asterisk(['user1' => ['name' => 'John'], 'user2' => ['name' => 'Robin']);
$asterisk->isEmpty('*.name'); // false
$asterisk->isEmpty('*.spouse'); // true
```

### merge()

[](#merge)

> It works like [Adbar\\Dot::merge()](https://github.com/adbario/php-dot-notation#merge)Asterisk in path Asterisk::merge('key', 'value') work like Asterisk::set('key', 'value', false)

### mergeRecursive()

[](#mergerecursive)

> It works like [Adbar\\Dot::mergeRecursive()](https://github.com/adbario/php-dot-notation#mergeRecursive)Asterisk in path Asterisk::mergeRecursive('key', 'value') work like Asterisk::set('key', 'value', false)

### mergeRecursiveDistinct()

[](#mergerecursivedistinct)

> It works like [Adbar\\Dot::mergeRecursiveDistinct()](https://github.com/adbario/php-dot-notation#mergeRecursiveDistinct)

### pull()

[](#pull)

Returns the value of a given key and deletes the key:

```
echo $asterisk->pull('user.name');

// Equivalent vanilla PHP < 7.0
echo isset($array['user']['name']) ? $array['user']['name'] : null;
unset($array['user']['name']);

// Equivalent vanilla PHP >= 7.0
echo $array['user']['name'] ?? null;
unset($array['user']['name']);
```

Returns a given default value, if the given key doesn't exist:

```
echo $asterisk->pull('user.name', 'some default value');
```

> Default value not work with asterisk in query!

Returns all the stored items as an array and clears the Dot object:

```
$items = $asterisk->pull();
```

Key with asterisk:

```
$asterisk = new \Setnemo\Asterisk([['user1' => ['name' => 'John', 'job' => 'warrior'], 'user2' => ['name' => 'Robin', 'job' => 'archer'],]]);
$result = $asterisk->pull('*.name'); // ['user1.name' => 'John', 'user2.name' => 'Robin']
$all = $asterisk->all(); // ['user1' => ['job' => 'warrior'], 'user2' => ['job' => 'archer'],]

```

### push()

[](#push)

Pushes a given value to the end of the array in a given key:

```
$asterisk->push('users', 'John');

// Equivalent vanilla PHP
$array['users'][] = 'John';
```

Pushes a given value to the end of the array:

```
$asterisk->push('John');

// Equivalent vanilla PHP
$array[] = 'John';
```

With asterisk:

```
$asterisk = new \Setnemo\Asterisk([
    'first_one' => ['second' => 'value'],
    'first_two' => ['second' => 'value']
]);
$asterisk->push('*.second', 'John');

$asterisk->all();
/*
[
    'first_one' => ['second' => ['value','VALUE']],
    'first_two' => ['second' => ['value','VALUE']]
]
 */
```

Also work as Asterisk::set('key', 'value', true), where true is asterisk boolean. See [Asterisk::set()](#set)

### replace()

[](#replace)

> It works like [Adbar\\Dot::replace()](https://github.com/adbario/php-dot-notation#replace)

### set()

[](#set)

Sets a given key / value pair:

```
$asterisk->set('user.name', 'John');

// ArrayAccess
$asterisk['user.name'] = 'John';

// Equivalent vanilla PHP
$array['user']['name'] = 'John';
```

Multiple key / value pairs:

```
$asterisk->set([
    'user.name' => 'John',
    'page.title'     => 'Home'
]);
```

### setArray()

[](#setarray)

> It works like [Adbar\\Dot::setarray()](https://github.com/adbario/php-dot-notation#setarray)

### setReference()

[](#setreference)

> It works like [Adbar\\Dot::setreference()](https://github.com/adbario/php-dot-notation#setreference)

### toJson()

[](#tojson)

> It works like [Adbar\\Dot::toJson()](https://github.com/adbario/php-dot-notation#toJson)

License
-------

[](#license)

[MIT license](LICENSE.txt)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.3% 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 ~5 days

Total

3

Last Release

1693d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2fb142df00897ebec215364e974c6863f141d732f80a6d490196aa6289479834?d=identicon)[setnemo](/maintainers/setnemo)

---

Top Contributors

[![setnemo](https://avatars.githubusercontent.com/u/7947055?v=4)](https://github.com/setnemo "setnemo (13 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

arraysasteriskasterisk-notationhacktoberfestnotationphpphp74php8

###  Code Quality

TestsCodeception

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/setnemo-asterisk-notation/health.svg)

```
[![Health](https://phpackages.com/badges/setnemo-asterisk-notation/health.svg)](https://phpackages.com/packages/setnemo-asterisk-notation)
```

###  Alternatives

[alibabacloud/client

Alibaba Cloud Client for PHP - Use Alibaba Cloud in your PHP project

2223.5M366](/packages/alibabacloud-client)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[crwlr/crawler

Web crawling and scraping library.

37214.8k2](/packages/crwlr-crawler)[brandembassy/slim-nette-extension

19190.2k](/packages/brandembassy-slim-nette-extension)[janiskelemen/laravel-setting

Laravel Settings Manager

5115.6k](/packages/janiskelemen-laravel-setting)[adbario/slim-secure-session-middleware

Secure session middleware for Slim 3 framework

2932.3k2](/packages/adbario-slim-secure-session-middleware)

PHPackages © 2026

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