Skip to content

Commit

Permalink
Move to phpowermove organization
Browse files Browse the repository at this point in the history
- Change namespace to `phpowermove\docblock`
- Update dependencies
- Fix coding standard
- Update README
- Fix Github Actions workflows
  • Loading branch information
cristianoc72 committed Sep 22, 2021
1 parent 363d370 commit 5954ae8
Show file tree
Hide file tree
Showing 53 changed files with 130 additions and 129 deletions.
1 change: 0 additions & 1 deletion .github/workflows/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ jobs:
- name: Deploy api documentation site
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.DOCBLOCK_TOKEN }}
publish_dir: ./api
10 changes: 3 additions & 7 deletions .github/workflows/coverage-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ jobs:
coverage: pcov
- name: Install dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: CodeClimate coverage report
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: "composer coverage:clover"
- name: Scrutinizer coverage report
- name: Generate coverage report
run: composer coverage:clover
- name: Upload coverage report to Scrutinizer
uses: sudo-bot/action-scrutinizer@latest
with:
cli-args: "--format=php-clover clover.xml"
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
clover.xml
composer.lock
composer.phar
.php.cs.cache
.phpunit.result.cache
*.cache
sami.phar
vendor/
api/
Expand Down
File renamed without changes.
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# Docblock

[![License](https://img.shields.io/github/license/gossi/docblock.svg?style=flat-square)](https://packagist.org/packages/gossi/docblock)
[![Latest Stable Version](https://img.shields.io/packagist/v/gossi/docblock.svg?style=flat-square)](https://packagist.org/packages/gossi/docblock)
[![Total Downloads](https://img.shields.io/packagist/dt/gossi/docblock.svg?style=flat-square&colorB=007ec6)](https://packagist.org/packages/gossi/docblock)
![Tests](https://github.com/gossi/docblock/workflows/Docblock%20Test%20Suite/badge.svg)
![Coverage report](https://github.com/phootwork/phootwork/workflows/Coverage/badge.svg)
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/gossi/docblock.svg?style=flat-square)](https://scrutinizer-ci.com/g/gossi/docblock)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/gossi/docblock.svg?style=flat-square)](https://scrutinizer-ci.com/g/gossi/docblock)
[![License](https://img.shields.io/github/license/phpowermove/docblock.svg?style=flat-square)](https://packagist.org/packages/phpowermove/docblock)
[![Latest Stable Version](https://img.shields.io/packagist/v/phpowermove/docblock.svg?style=flat-square)](https://packagist.org/packages/phpowermove/docblock)
[![Total Downloads](https://img.shields.io/packagist/dt/phpowermove/docblock.svg?style=flat-square&colorB=007ec6)](https://packagist.org/packages/phpowermove/docblock)
![Tests](https://github.com/phpowermove/docblock/workflows/Docblock%20Test%20Suite/badge.svg)
![Coverage report](https://github.com/phpowermove/docblock/workflows/Coverage/badge.svg)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/phpowermove/docblock/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/phpowermove/docblock/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/phpowermove/docblock/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/phpowermove/docblock/?branch=master)

PHP Docblock parser and generator. An API to read and write Docblocks.

> __WARNING__: starting from version 4.0 the library has moved to [phpowermove organization](https://github.com/phpowermove) and the namespace is `phpowermove\docblock`.
## Installation

Install via Composer:

```
composer require gossi/docblock
composer require phpowermove/docblock
```

## Usage
Expand All @@ -25,15 +27,15 @@ composer require gossi/docblock
a) Simple:

```php
use gossi\docblock\Docblock;
use phpowermove\docblock\Docblock;

$docblock = new Docblock();
```

b) Create from string:

```php
use gossi\docblock\Docblock;
use phpowermove\docblock\Docblock;

$docblock = new Docblock('/**
* Short Description.
Expand All @@ -47,7 +49,7 @@ $docblock = new Docblock('/**
c) Create from reflection:

```php
use gossi\docblock\Docblock;
use phpowermove\docblock\Docblock;

$docblock = new Docblock(new \ReflectionClass('MyClass'));
```
Expand All @@ -69,7 +71,7 @@ $tags = $docblock->getTags('author');
Append a tag:

```php
use gossi\docblock\tags\AuthorTag;
use phpowermove\docblock\tags\AuthorTag;

$author = new AuthorTag();
$author->setName('gossi');
Expand All @@ -79,7 +81,7 @@ $docblock->appendTag($author);
or with fluent API:

```php
use gossi\docblock\tags\AuthorTag;
use phpowermove\docblock\tags\AuthorTag;

$docblock->appendTag(AuthorTag::create()
->setName('gossi')
Expand Down Expand Up @@ -108,7 +110,7 @@ echo $docblock;

## Documentation Api

See https://gossi.github.io/docblock
See https://phpowermove.github.io/docblock

## Contributing

Expand All @@ -120,4 +122,4 @@ Feel free to fork and submit a pull request (don't forget the tests) and I am ha

## Changelog

Refer to [Releases](https://github.com/gossi/docblock/releases)
Refer to [Releases](https://github.com/phpowermove/docblock/releases)
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
"generator"
],
"support" : {
"issues" : "https://github.com/gossi/docblock/issues"
"issues" : "https://github.com/phpowermove/docblock/issues"
},
"autoload" : {
"psr-4" : {
"gossi\\docblock\\" : "src/"
"phpowermove\\docblock\\" : "src/"
}
},
"autoload-dev" : {
"psr-4" : {
"gossi\\docblock\\tests\\" : "tests/"
"phpowermove\\docblock\\tests\\" : "tests/"
}
},
"require" : {
Expand All @@ -33,7 +33,7 @@
},
"require-dev" : {
"phpunit/phpunit" : "^9.0",
"phootwork/php-cs-fixer-config": "^0.3",
"phootwork/php-cs-fixer-config": "^0.4",
"psalm/phar": "^4.3"
},
"scripts": {
Expand Down
11 changes: 6 additions & 5 deletions src/Docblock.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
* @license MIT License
*/

namespace gossi\docblock;
namespace phpowermove\docblock;

use gossi\docblock\tags\AbstractTag;
use gossi\docblock\tags\TagFactory;
use InvalidArgumentException;
use LogicException;
use phootwork\collection\ArrayList;
use phootwork\collection\Map;
use phootwork\lang\Comparator;
use phpowermove\docblock\tags\AbstractTag;
use phpowermove\docblock\tags\TagFactory;
use ReflectionClass;
use ReflectionFunctionAbstract;
use ReflectionProperty;
Expand All @@ -26,7 +26,7 @@ class Docblock implements \Stringable {
protected ArrayList $tags;
protected ?Comparator $comparator = null;

const REGEX_TAGNAME = '[\w\-\_\\\\]+';
public const REGEX_TAGNAME = '[\w\-\_\\\\]+';

/**
* Static docblock factory
Expand Down Expand Up @@ -307,7 +307,8 @@ public function removeTags(string $tagName = ''): void {
* @return bool
*/
public function hasTag(string $tagName): bool {
return $this->tags->search($tagName,
return $this->tags->search(
$tagName,
fn (AbstractTag $tag, string $query): bool => $tag->getTagName() === $query
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/TagNameComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT License
*/

namespace gossi\docblock;
namespace phpowermove\docblock;

use phootwork\lang\Comparator;

Expand Down
2 changes: 1 addition & 1 deletion src/tags/AbstractDescriptionTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT License
*/

namespace gossi\docblock\tags;
namespace phpowermove\docblock\tags;

/**
* Abstract tag with a description
Expand Down
4 changes: 2 additions & 2 deletions src/tags/AbstractTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT License
*/

namespace gossi\docblock\tags;
namespace phpowermove\docblock\tags;

use phootwork\lang\Text;

Expand All @@ -32,7 +32,7 @@ public static function create(string $content = ''): self {
*/
final public function __construct(string $content = '') {
$this->tagName = Text::create(get_class($this))
->trimStart('gossi\\docblock\\tags\\')
->trimStart('phpowermove\\docblock\\tags\\')
->trimEnd('Tag')
->toKebabCase()
->toString()
Expand Down
2 changes: 1 addition & 1 deletion src/tags/AbstractTypeTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT License
*/

namespace gossi\docblock\tags;
namespace phpowermove\docblock\tags;

/**
* Represents tags which are in the format
Expand Down
4 changes: 2 additions & 2 deletions src/tags/AbstractVarTypeTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT License
*/

namespace gossi\docblock\tags;
namespace phpowermove\docblock\tags;

use phootwork\lang\Text;

Expand All @@ -22,7 +22,7 @@ abstract class AbstractVarTypeTag extends AbstractTypeTag {

/**
* @see https://github.com/phpDocumentor/ReflectionDocBlock/blob/master/src/phpDocumentor/Reflection/DocBlock/Tag/ParamTag.php Original Method: setContent()
* @see \gossi\docblock\tags\AbstractTypeTag::parse()
* @see \phpowermove\docblock\tags\AbstractTypeTag::parse()
*
* @param string $content
*/
Expand Down
13 changes: 7 additions & 6 deletions src/tags/AbstractVersionTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT License
*/

namespace gossi\docblock\tags;
namespace phpowermove\docblock\tags;

/**
* Represents tags which are in the format
Expand All @@ -20,7 +20,7 @@ abstract class AbstractVersionTag extends AbstractDescriptionTag {
* PCRE regular expression matching a version vector.
* Assumes the "x" modifier.
*/
const REGEX_VERSION = '(?:
public const REGEX_VERSION = '(?:
# Normal release vectors.
\d\S*
|
Expand All @@ -36,22 +36,23 @@ abstract class AbstractVersionTag extends AbstractDescriptionTag {

/**
* @see https://github.com/phpDocumentor/ReflectionDocBlock/blob/master/src/phpDocumentor/Reflection/DocBlock/Tag/VersionTag.php Original Method: setContent()
* @see \gossi\docblock\tags\AbstractTag::parse()
* @see \phpowermove\docblock\tags\AbstractTag::parse()
*
* @param string $content
*/
protected function parse(string $content): void {
$matches = [];
if (preg_match(
'/^
'/^
# The version vector
(' . self::REGEX_VERSION . ')
\s*
# The description
(.+)?
$/sux',
$content,
$matches)) {
$content,
$matches
)) {
$this->version = $matches[1];
$this->setDescription($matches[2] ?? '');
}
Expand Down
15 changes: 9 additions & 6 deletions src/tags/AuthorTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT License
*/

namespace gossi\docblock\tags;
namespace phpowermove\docblock\tags;

/**
* Represents the `@author` tag.
Expand All @@ -19,26 +19,29 @@ class AuthorTag extends AbstractTag {
/**
* PCRE regular expression matching any valid value for the name component.
*/
const REGEX_AUTHOR_NAME = '[^\<]*';
public const REGEX_AUTHOR_NAME = '[^\<]*';

/**
* PCRE regular expression matching any valid value for the email component.
*/
const REGEX_AUTHOR_EMAIL = '[^\>]*';
public const REGEX_AUTHOR_EMAIL = '[^\>]*';

protected string $name = '';
protected string $email = '';

/**
* @see https://github.com/phpDocumentor/ReflectionDocBlock/blob/master/src/phpDocumentor/Reflection/DocBlock/Tag/AuthorTag.php Original Method: setContent()
* @see \gossi\docblock\tags\AbstractTag::parse()
* @see \phpowermove\docblock\tags\AbstractTag::parse()
*
* @param string $content
*/
protected function parse(string $content): void {
$matches = [];
if (preg_match('/^(' . self::REGEX_AUTHOR_NAME . ')(\<(' . self::REGEX_AUTHOR_EMAIL . ')\>)?$/u',
$content, $matches)) {
if (preg_match(
'/^(' . self::REGEX_AUTHOR_NAME . ')(\<(' . self::REGEX_AUTHOR_EMAIL . ')\>)?$/u',
$content,
$matches
)) {
$this->name = trim($matches[1]);
if (isset($matches[3])) {
$this->email = trim($matches[3]);
Expand Down
2 changes: 1 addition & 1 deletion src/tags/DeprecatedTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT License
*/

namespace gossi\docblock\tags;
namespace phpowermove\docblock\tags;

/**
* Represents the `@deprecated` tag.
Expand Down
2 changes: 1 addition & 1 deletion src/tags/LicenseTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT License
*/

namespace gossi\docblock\tags;
namespace phpowermove\docblock\tags;

/**
* Represents a `@license` tag.
Expand Down
4 changes: 2 additions & 2 deletions src/tags/LinkTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT License
*/

namespace gossi\docblock\tags;
namespace phpowermove\docblock\tags;

/**
* Represents a `@link` tag
Expand All @@ -24,7 +24,7 @@ class LinkTag extends AbstractDescriptionTag {
*
* @var string
*/
const URL_REGEX = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:/[^\s]*)?$_iuS';
public const URL_REGEX = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:/[^\s]*)?$_iuS';

protected function parse(string $content): void {
$parts = preg_split('/\s+/Su', $content, 2);
Expand Down
2 changes: 1 addition & 1 deletion src/tags/MethodTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT License
*/

namespace gossi\docblock\tags;
namespace phpowermove\docblock\tags;

/**
* Represents the `@method` tag.
Expand Down
Loading

0 comments on commit 5954ae8

Please sign in to comment.