PHPackages                             ilya/block - 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. ilya/block

ActiveLibrary

ilya/block
==========

Parsing docblocks made easy

1.5.0(11y ago)21311MITPHPPHP &gt;=5.4.0

Since Apr 13Pushed 11y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (9)Used By (1)

Block
=====

[](#block)

[![Build Status](https://camo.githubusercontent.com/293b11e647ea67b940e1feb51c29c3ff2f05913bd9cc99880d483ef0fd2fecde/68747470733a2f2f7472617669732d63692e6f72672f696c79612d6465762f626c6f636b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ilya-dev/block)

*Block* makes parsing PHP DocBlocks easier.

Simple, documented and fully tested. PHP 5.4 is required.

Installation
------------

[](#installation)

Using Composer: `composer require "ilya/block:~1"`.

Example
-------

[](#example)

Imagine you have the following code:

```
class Foo {

    /**
     * The Bar.
     *
     * @var integer
     */
    protected $bar;

    /**
     * The Baz.
     *
     * @var string
     */
    public $baz;

    /**
     * Do Amaze.
     *
     * @param string $amaze
     * @return void
     */
    private function wow($amaze)
    {

    }

}
```

First, instantiate Block, like so: `$block = new Block\Block(new Foo);`.

Now you can begin to inspect the docblocks using these 4 methods available.

- `Block\Comment property(string $name)`
- `array properties(integer $filter)`
- `Block\Comment method(string $name)`
- `array methods(integer $filter)`
- `Block\Comment reflector(Reflector $reflector)`

Methods `property` and `method` will receive a name (as a string) and return an instance of `Block\Comment`. Methods `properties` and `methods` will receive an optional argument `$filter`and return an array of `Block\Comment` instances.

If you are wondering what that `$filter` thing is, take a look at the example:

```
$block->methods(ReflectionMethod::IS_PUBLIC); // only fetch public methods

// only fetch private AND protected properties
$block->properties(ReflectionProperty::IS_PRIVATE | ReflectionProperty::IS_PROTECTED);
```

Ok, so now that you have an instance (or many of them) of `\Block\Comment`, what kind of actions can you perform?

- convert the instance to a string: `$comment->getComment()`. Note that `(string) $comment` would work too!
- split it into lines: `$comment->getLines()`.

Let's review the second option.

Calling the `getLines()` method will return an array, each element of which is an instance of `\Block\Line`.

Here's what it offers:

- `boolean isTag(void)` - determine whether the line contains a tag: will be true for `@param int $speed` and false for `My desc`.
- `string getLine(void)` - get the line itself, as a string, note that `(string) $line` would also work.
- `array tokenize(void)` - split the line into "tokens" - e.g `@param int $speed` will be represented as `['@param', 'int', '$speed']`. All white spaces are ignored.
- `string stripTag(void)`

So that's it, hopefully you now can start to use Block in your projects.

License
-------

[](#license)

Block is licensed under the MIT license.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Total

8

Last Release

4355d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/776b7b64a5d05531a18e8874c09069a25dce24b2e3efa60ea521e25e9a35281a?d=identicon)[ilya.s](/maintainers/ilya.s)

---

Top Contributors

[![ilya-dev](https://avatars.githubusercontent.com/u/6959318?v=4)](https://github.com/ilya-dev "ilya-dev (48 commits)")

---

Tags

phpdocumentationreflectionparsingblocksdocsdocblocks

### Embed Badge

![Health badge](/badges/ilya-block/health.svg)

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

###  Alternatives

[binarytorch/larecipe

Generate gorgeous recipes for your Laravel applications using MarkDown

2.5k2.7M16](/packages/binarytorch-larecipe)[tartanlegrand/laravel-openapi

Generate OpenAPI Specification for Laravel Applications

38178.7k2](/packages/tartanlegrand-laravel-openapi)[yaro/apidocs

Api documentation generator for Laravel 5

114.1k](/packages/yaro-apidocs)

PHPackages © 2026

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