2017 © Pedro Peláez
 

library better-phpdoc-parser

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

image

symplify/better-phpdoc-parser

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 335 % Grown

The README.md

Deprecated, moved to Rector

Better PhpDoc Parser

Build Status Downloads, (*1)

Wrapper around phpstan/phpdoc-parser that adds format preserving printer., (*2)

When do We Need Format Preserving Printer?

Original code, (*3)

/**
 * @param   string   $name
 * @param   string   $surname
 * @return  bool
  */

Printed by PHPStan PhpDocParser :x:, (*4)

/**
 * @param string $name
 * @param string $surname
 * @return bool
 */

Printed by Better PhpDocParser :+1:, (*5)

/**
 * @param   string   $name
 * @param   string   $surname
 * @return  bool
 */

Symplify\CodingStandard and Rector need to modify docblock and put it back in correct format. Other packages often put own spacing, or formats of specific tags., (*6)

This package preserve original spacing., (*7)

Thanks for inspiration in Format Preserving Printer feature in nikic/php-parser., (*8)

Install

composer require symplify/better-phpdoc-parser

Usage

Register services in your Symfony config:, (*9)

# services.yaml
imports:
    - { resource: 'vendor/symplify/better-phpdoc-parser/config/config.yml' }

or register the needed services from services.yaml in config of your other framework., (*10)

<?php

use Symplify\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Symplify\BetterPhpDocParser\Printer\PhpDocInfoPrinter;

class SomeClass
{
    public function __construct(PhpDocInfoFactory $phpDocInfoFactory, PhpDocInfoPrinter $phpDocInfoPrinter)
    {
        $this->phpDocInfoFactory = $phpDocInfoFactory;
        $this->phpDocInfoPrinter = $phpDocInfoPrinter;
    }

    public function changeDocBlockAndPrintItBack(): string
    {
        $docComment = '/**    @var Type $variable    */';

        $phpDocInfo = $this->phpDocInfoFactory->createFrom($docComment);

        // modify `$phpDocInfo` using its methods

        return $this->phpDocInfoPrinter->printFormatPreserving($phpDocInfo);
    }
}

The Versions

24/07 2018

dev-master

9999999-dev

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  Sources   Download

MIT

The Requires

 

The Development Requires

14/07 2018

v4.5.1

4.5.1.0

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  Sources   Download

MIT

The Requires

 

The Development Requires

30/06 2018

v4.5.0

4.5.0.0

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  Sources   Download

MIT

The Requires

 

The Development Requires

10/06 2018

v4.4.2

4.4.2.0

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  Sources   Download

MIT

The Requires

 

The Development Requires

03/06 2018

v4.4.1

4.4.1.0

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  Sources   Download

MIT

The Requires

 

The Development Requires

03/06 2018

v4.4.0

4.4.0.0

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  Sources   Download

MIT

The Requires

 

The Development Requires

20/05 2018

v4.3.0

4.3.0.0

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  Sources   Download

MIT

The Requires

 

The Development Requires

12/05 2018

v4.2.1

4.2.1.0

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  Sources   Download

MIT

The Requires

 

The Development Requires

12/05 2018

v4.2.2

4.2.2.0

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  Sources   Download

MIT

The Requires

 

The Development Requires

12/05 2018

v4.2.3

4.2.3.0

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  Sources   Download

MIT

The Requires

 

The Development Requires

06/05 2018

v4.2.0

4.2.0.0

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  Sources   Download

MIT

The Requires

 

The Development Requires

02/05 2018

v4.1.2

4.1.2.0

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  Sources   Download

MIT

The Requires

 

The Development Requires

25/04 2018

v4.1.1

4.1.1.0

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  Sources   Download

MIT

The Requires

 

The Development Requires

24/04 2018

v4.1.0

4.1.0.0

Slim wrapper around phpstan/phpdoc-parser with format preserving printer

  Sources   Download

MIT

The Requires

 

The Development Requires