<commit_before>IniParser is a really simple parser for "complex" INI files.

Standard INI files look like this:

    key = value
    another_key = another value
    
    [section_name]
    a_sub_key = yet another value

And when parsed with PHP's built-in `parse_ini_string()` or `parse_ini_file()`, looks like

    array(
        'key' => 'value',
        'another_key' => 'another value',
        'section_name' => array(
            'a_sub_key' => 'yet another value'
        )
    )

This is great when you just want a super simple configuration file, but here is a super-charged INI file that you might find in the wild:

    environment = testing
    
    [testing]
    debug = true
    database.connection = "mysql:host=127.0.0.1"
    database.name = test
    database.username = 
    database.password =
    secrets = [1,2,3]
    
    [staging : testing]
    database.name = stage
    database.username = staging
    database.password = <PASSWORD>
    
    [production : staging]
    debug = false;
    database.name = production
    database.username = root

And when parsed with IniParser:

    array(
        'environment' => 'testing',
        'testing' => array(
            'debug' => '1',
            'database' => array(
                'connection' => 'mysql:host=127.0.0.1',
                'name' => 'test',
                'username' => '',
                'password' => ''
            ),
            'secrets' => array('1','2','3')
        ),
        'staging' => array(
            'debug' => '1',
            'database' => array(
                'connection' => 'mysql:host=127.0.0.1',
                'name' => 'stage',
                'username' => 'staging',
                'password' => '<PASSWORD>'
            ),
            'secrets' => array('1','2','3')
        ),
        'production' => array(
            'debug' => '',
            'database' => array(
                'connection' => 'mysql:host=127.0.0.1',
                'name' => 'production',
                'username' => 'root',
                'password' => '<PASSWORD>'
            ),
            'secrets' => array('1','2','3')
        )
    )

As you can see, IniParser supports section inheritance with `[child : parent]`, property nesting with `a.b.c = d`, and simple arrays with `[a,b,c]`.

Additionally, you can sub-class IniParser and override the `parse_key()` and `parse_value()` methods to customize how it parses keys and values.<commit_msg> * improve formatting  * add note about object-style-notation<commit_after># IniParser

IniParser is a really simple parser for "complex" INI files.

## Examples

Standard INI files look like this:

    key = value
    another_key = another value
    
    [section_name]
    a_sub_key = yet another value

And when parsed with PHP's built-in `parse_ini_string()` or `parse_ini_file()`, looks like

    array(
        'key' => 'value',
        'another_key' => 'another value',
        'section_name' => array(
            'a_sub_key' => 'yet another value'
        )
    )

### Complex example

This is great when you just want a super simple configuration file, but here is a super-charged INI file that you might find in the wild:

    environment = testing
    
    [testing]
    debug = true
    database.connection = "mysql:host=127.0.0.1"
    database.name = test
    database.username = 
    database.password =
    secrets = [1,2,3]
    
    [staging : testing]
    database.name = stage
    database.username = staging
    database.password = <PASSWORD>
    
    [production : staging]
    debug = false;
    database.name = production
    database.username = root

And when parsed with IniParser:

    array(
        'environment' => 'testing',
        'testing' => array(
            'debug' => '1',
            'database' => array(
                'connection' => 'mysql:host=127.0.0.1',
                'name' => 'test',
                'username' => '',
                'password' => ''
            ),
            'secrets' => array('1','2','3')
        ),
        'staging' => array(
            'debug' => '1',
            'database' => array(
                'connection' => 'mysql:host=127.0.0.1',
                'name' => 'stage',
                'username' => 'staging',
                'password' => '<PASSWORD>'
            ),
            'secrets' => array('1','2','3')
        ),
        'production' => array(
            'debug' => '',
            'database' => array(
                'connection' => 'mysql:host=127.0.0.1',
                'name' => 'production',
                'username' => 'root',
                'password' => '<PASSWORD>'
            ),
            'secrets' => array('1','2','3')
        )
    )

### Additional Features

As you can see, IniParser supports section inheritance with `[child : parent]`, property nesting with `a.b.c = d`, and simple arrays with `[a,b,c]`.

Additionally, you can sub-class IniParser and override the `parse_key()` and `parse_value()` methods to customize how it parses keys and values.

### ArrayObject

As an added bonus, IniParser also allows you to access the values OO-style:

    echo $config->production->database->connection; // output: mysql:host=127.0.0.1
    echo $config->staging->debug; // output: 1

{'fraction_non_alphanumeric': 0.13923326339881748, 'fraction_numerical': 0.01583063131794774, 'mean_word_length': 1.9527027027027026, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 72, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 9, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1724167', 'n_tokens_mistral': 1584, 'n_tokens_neox': 1508, 'n_words': 430}