PHPackages                             tomasvotruba/lines - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. tomasvotruba/lines

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

tomasvotruba/lines
==================

Measuring the size of PHP project and its PHP features

1.2.0(5mo ago)339289.6k↓14.1%10[2 issues](https://github.com/TomasVotruba/lines/issues)4MITPHPPHP &gt;=7.2CI passing

Since Jul 27Pushed 4mo ago4 watchersCompare

[ Source](https://github.com/TomasVotruba/lines)[ Packagist](https://packagist.org/packages/tomasvotruba/lines)[ Fund](https://www.paypal.me/rectorphp)[ GitHub Sponsors](https://github.com/tomasvotruba)[ RSS](/packages/tomasvotruba-lines/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (28)Used By (4)

Lines of code and PHP Features
==============================

[](#lines-of-code-and-php-features)

CLI tool for quick size measure of PHP project, and real used PHP features.

Zero dependencies. Runs anywhere.

What are killer features?
-------------------------

[](#what-are-killer-features)

- install anywhere - PHP 7.2? PHPUnit 6? Symfony 3? Not a problem, this package **has zero dependencies and works on PHP 7.2+**
- get quick overview of your project size - no details, no complexity, just lines of code
- get easy **JSON output** for further processing
- measure **used PHP features in your project** - how much PHP 8.0-features used? How many attributes? How many arrow function? How many union types?

Install
-------

[](#install)

The package is scoped and downgraded to PHP 7.2. So you can install it anywhere with any set of dependencies:

```
composer require tomasvotruba/lines --dev
```

1. Measure Lines and Size
-------------------------

[](#1-measure-lines-and-size)

```
vendor/bin/lines measure
```

By default, we measure the root directory. To narrow it down, provide explicit path:

```
vendor/bin/lines measure src
```

For short output:

```
vendor/bin/lines measure --short
```

For json output, just add `--json`:

```
vendor/bin/lines measure --json
```

Also, you can combine them (very handy for blog posts and tweets):

```
vendor/bin/lines measure --short --json
```

For the text output, you'll get data like these:

```
  Filesystem                                         count
  Directories ......................................... 32
  Files .............................................. 160

  Lines of code                           count / relative
  Code ................................... 15 521 / 70.9 %
  Comments ................................ 6 372 / 29.1 %
  Total .................................. 21 893 /  100 %

  Structure                                          count
  Namespaces .......................................... 32
  Classes ............................................ 134
   * Constants ........................................ 91
   * Methods ....................................... 1 114
  Interfaces .......................................... 20
  Traits ............................................... 4
  Enums ................................................ 1
  Functions ........................................... 36
  Global constants ..................................... 0

  Methods                                 count / relative
  Non-static .............................. 1 058 /   95 %
  Static ..................................... 56 /    5 %

  Public .................................... 875 / 78.5 %
  Protected .................................. 90 /  8.1 %
  Private ................................... 149 / 13.4 %

```

Or in a json format:

```
{
    "filesystem": {
        "directories": 10,
        "files": 15
    },
    "lines_of_code": {
        "code": 1064,
        "code_relative": 95.4,
        "comments": 51,
        "comments_relative": 4.6,
        "total": 1115
    },
    "structure": {
        "namespaces": 11,
        "classes": 14,
        "class_methods": 88,
        "class_constants": 0,
        "interfaces": 1,
        "traits": 0,
        "enums": 0,
        "functions": 5,
        "global_constants": 3
    },
    "methods_access": {
        "non_static": 82,
        "non_static_relative": 93.2,
        "static": 6,
        "static_relative": 6.8
    },
    "methods_visibility": {
        "public": 70,
        "public_relative": 79.5,
        "protected": 2,
        "protected_relative": 2.3,
        "private": 16,
        "private_relative": 18.2
    }
}
```

### Longest files

[](#longest-files)

Are you looking for top 10 longest files?

```
vendor/bin/lines measure --longest
```

```
  Longest files                                 line count
  src/Measurements.php ............................... 320
  src/Console/OutputFormatter/TextOutputFormatter.php  136
  src/NodeVisitor/StructureNodeVisitor.php ........... 124
  src/Console/Command/MeasureCommand.php .............. 98
  src/Analyser.php .................................... 92

```

### Scan package in `/vendor`

[](#scan-package-in-vendor)

This tool measures *your code*, not the 3rd party libraries. It skips `/vendor` directory by default to avoid false positives. If you want to measure vendor files too, use `--allow-vendor` option:

```
 vendor/bin/lines measure vendor/rector/rector --allow-vendor
```

2. PHP Feature Counter
----------------------

[](#2-php-feature-counter)

Two codebases using PHP 8.4 in `composer.json`, are not the same codebases. One has zero type param/return/property declarations, other has promoted properties. Reveal their real value by counting PHP feature they actually use.

```
vendor/bin/lines features src
```

For json output, just add `--json`:

```
vendor/bin/lines features src --json
```

This command:

- scans your codebase,
- count PHP feature being used from which PHP version,
- gives you quick overview of how modern the codebase really is

For the text output, you'll get data like these:

```
PHP features
============

 ------------- ----------------------------------------------- ------------
  PHP version   PHP Feature                                     Count
 ------------- ----------------------------------------------- ------------
  7.0           Parameter types                                      2 793
  7.0           Return types                                         1 736
  7.0           Strict declares                                        492
  7.0           Space ship  operator                                  0
 ------------- ----------------------------------------------- ------------
  7.1           Nullable type (?type)                                  333
  7.1           Void return type                                       317
  7.1           Class constant visibility                              557
 ------------- ----------------------------------------------- ------------
  7.2           Object type                                             14
 ------------- ----------------------------------------------- ------------
  7.3           Coalesce ?? operator                                    69
 ------------- ----------------------------------------------- ------------
  7.4           Typed properties                                       156
  7.4           Arrow functions                                         38
  7.4           Coalesce assign (??=)                                    0
 ------------- ----------------------------------------------- ------------
  8.0           Named arguments                                         10
  8.0           Union types                                            147
  8.0           Match expression                                         1
  8.0           Nullsafe method call/property fetch                      0
  8.0           Attributes                                               0
  8.0           Throw expression                                       111
  8.0           Promoted properties                                    596
 ------------- ----------------------------------------------- ------------
  8.1           First-class callables                                    8
  8.1           Readonly property                                        3
  8.1           Intersection types                                       0
  8.1           Enums                                                    0
 ------------- ----------------------------------------------- ------------
  8.2           Readonly class                                         182
 ------------- ----------------------------------------------- ------------
  8.3           Typed class constants                                    0
 ------------- ----------------------------------------------- ------------
  8.4           Property hooks                                           0
 ------------- ----------------------------------------------- ------------

```

Or in a json format:

```
{
    "7.0": [
        {
            "name": "Parameter types",
            "count": 122
        },
        {
            "name": "Return types",
            "count": 143
        },
        {
            "name": "Strict declares",
            "count": 31
        },
        {
            "name": "Space ship  operator ",
            "count": 0
        },
        {
            "name": "Coalesce ?? operator",
            "count": 1
        }
    ],
    "7.1": [
        {
            "name": "Nullable type (?type)",
            "count": 5
        },
        {
            "name": "Void return type",
            "count": 48
        },
        {
            "name": "Class constant visibility",
            "count": 15
        }
    ],
    "7.2": [
        {
            "name": "Object type",
            "count": 3
        }
    ],
    "7.4": [
        {
            "name": "Typed properties",
            "count": 26
        },
        {
            "name": "Arrow functions",
            "count": 25
        },
        {
            "name": "Coalesce assign (??=)",
            "count": 0
        }
    ],
    "8.0": [
        {
            "name": "Named arguments",
            "count": 14
        },
        {
            "name": "Union types",
            "count": 5
        },
        {
            "name": "Match expression",
            "count": 0
        },
        {
            "name": "Nullsafe method call\/property fetch",
            "count": 0
        },
        {
            "name": "Attributes",
            "count": 0
        },
        {
            "name": "Throw expression",
            "count": 0
        },
        {
            "name": "Promoted properties",
            "count": 30
        }
    ],
    "8.1": [
        {
            "name": "First-class callables",
            "count": 0
        },
        {
            "name": "Readonly property",
            "count": 0
        },
        {
            "name": "Intersection types",
            "count": 0
        },
        {
            "name": "Enums",
            "count": 1
        }
    ],
    "8.2": [
        {
            "name": "Readonly class",
            "count": 6
        }
    ],
    "8.3": [
        {
            "name": "Typed class constants",
            "count": 9
        }
    ],
    "8.4": [
        {
            "name": "Property hooks",
            "count": 0
        }
    ]
}
```

That's it. Happy coding!

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance74

Regular maintenance activity

Popularity54

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.7% 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 ~34 days

Recently: every ~28 days

Total

26

Last Release

165d ago

Major Versions

0.7.1 → 1.0.02025-09-25

PHP version history (2 changes)0.1.0PHP ^8.1

0.1.0.72PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/924196?v=4)[Tomas Votruba](/maintainers/TomasVotruba)[@TomasVotruba](https://github.com/TomasVotruba)

---

Top Contributors

[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (78 commits)")[![llaville](https://avatars.githubusercontent.com/u/364342?v=4)](https://github.com/llaville "llaville (6 commits)")[![ssnepenthe](https://avatars.githubusercontent.com/u/10903810?v=4)](https://github.com/ssnepenthe "ssnepenthe (2 commits)")[![FeBe95](https://avatars.githubusercontent.com/u/7470739?v=4)](https://github.com/FeBe95 "FeBe95 (1 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (1 commits)")[![shakaran](https://avatars.githubusercontent.com/u/14254?v=4)](https://github.com/shakaran "shakaran (1 commits)")[![xiCO2k](https://avatars.githubusercontent.com/u/823088?v=4)](https://github.com/xiCO2k "xiCO2k (1 commits)")

---

Tags

astfeatureslines-of-codemeasurephpsize

### Embed Badge

![Health badge](/badges/tomasvotruba-lines/health.svg)

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

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