2017 © Pedro PelĂĄez
 

library token

Provides a simple abstraction for a token and a sequence of tokens.

image

localheinz/token

Provides a simple abstraction for a token and a sequence of tokens.

  • Saturday, January 27, 2018
  • by localheinz
  • Repository
  • 1 Watchers
  • 2 Stars
  • 158 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

token

CI Status codecov Latest Stable Version Total Downloads, (*1)

Provides a simple read-only abstraction for a token and a sequence of tokens, inspired by friendsofphp/php-cs-fixer., (*2)

Installation

Run, (*3)

$ composer require localheinz/token

Usage

Sequence of tokens

Create a sequence of tokens from source code:, (*4)

use Localheinz\Token\Sequence;

$source = <<<'PHP'
<?php

class Foo
{
    /**
     * @param Bar $bar
     */
    public function __construct(Bar $bar)
    {
        $this->bar = $bar;
    }
}
PHP;

$sequence = Sequence::fromSource($source);

Token in sequence

Retrieve the token at an index in the sequence of tokens:, (*5)

use Localheinz\Token\Token;

/** @var Token $token */
$token = $sequence->at(10);

var_dump($token->index()); // 10
var_dump($token->isType(T_PUBLIC)); // true
var_dump($token->isContent('public')); // true

Retrieve the next significant token before an index in the sequence of tokens:, (*6)

use Localheinz\Token\Token;

/** @var Token $before */
$before = $sequence->significantBefore(10);

var_dump($before->index()); // 6
var_dump($before->isType(T_STRING)); // true
var_dump($before->isContent('{')); // true

Retrieve the next significant token after an index in the sequence of tokens:, (*7)

use Localheinz\Token\Token;

/** @var Token $after */
$after = $sequence->significantAfter(10);

var_dump($after->index()); // 12
var_dump($after->isType(T_FUNCTION)); // true
var_dump($after->isContent('function')); // true

Changelog

Please have a look at CHANGELOG.md., (*8)

Contributing

Please have a look at CONTRIBUTING.md., (*9)

Code of Conduct

Please have a look at CODE_OF_CONDUCT.md., (*10)

License

This package is licensed using the MIT License., (*11)

The Versions

27/01 2018

dev-master

9999999-dev https://github.com/localheinz/token

Provides a simple abstraction for a token and a sequence of tokens.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Andreas Möller

27/01 2018

dev-feature/urls

dev-feature/urls https://github.com/localheinz/token

Provides a simple abstraction for a token and a sequence of tokens.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Andreas Möller

24/12 2017

dev-feature/infection

dev-feature/infection

Provides a simple abstraction for a token and a sequence of tokens.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Andreas Möller

09/10 2017

0.2.2

0.2.2.0

Provides a simple abstraction for a token and a sequence of tokens.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Andreas Möller

09/10 2017

0.2.1

0.2.1.0

Provides a simple abstraction for a token and a sequence of tokens.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Andreas Möller

04/10 2017

0.2.0

0.2.0.0

Provides a simple abstraction for a token and a sequence of tokens.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Andreas Möller

03/10 2017

0.1.0

0.1.0.0

Provides a simple abstraction for a token and a sequence of tokens.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Andreas Möller

26/09 2017

dev-fix/readme

dev-fix/readme

Provides a simple abstraction for a token and a sequence of tokens.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Andreas Möller