Repository: phpDocumentor/ReflectionCommon
Branch: 2.x
Commit: ee15a5a2022c
Files: 22
Total size: 18.9 KB
Directory structure:
gitextract_5ulacfom/
├── .gitattributes
├── .github/
│ ├── dependabot.yml
│ └── workflows/
│ └── integrate.yaml
├── .gitignore
├── .yamllint.yaml
├── LICENSE
├── Makefile
├── README.md
├── composer.json
├── phive.xml
├── phpcs.xml.dist
├── phpmd.xml.dist
├── phpstan.neon
├── phpunit.xml.dist
├── psalm.xml
├── src/
│ ├── Element.php
│ ├── File.php
│ ├── Fqsen.php
│ ├── Location.php
│ ├── Project.php
│ └── ProjectFactory.php
└── tests/
└── unit/
└── FqsenTest.php
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
/.github/ export-ignore
/tests/ export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.scrutinizer.yml export-ignore
/Makefile export-ignore
/composer.lock export-ignore
/phive.xml export-ignore
/phpcs.xml.dist export-ignore
/phpmd.xml.dist export-ignore
/phpstan.neon export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml export-ignore
================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
================================================
FILE: .github/workflows/integrate.yaml
================================================
# https://docs.github.com/en/actions
name: "Integrate"
on: # yamllint disable-line rule:truthy
push:
branches:
- "5.x"
pull_request: null
# Allow manually triggering the workflow.
workflow_dispatch: null
jobs:
code-coverage:
name: "Code Coverage"
uses: "phpDocumentor/.github/.github/workflows/code-coverage.yml@main"
with:
composer-root-version: "2.x-dev"
coding-standards:
name: "Coding Standards"
uses: "phpDocumentor/.github/.github/workflows/coding-standards.yml@v0.8"
with:
composer-root-version: "2.x-dev"
lint-root:
name: "Lint root"
uses: "phpDocumentor/.github/.github/workflows/lint.yml@main"
with:
composer-options: "--no-check-publish --ansi"
static-analysis:
name: "Static analysis"
uses: "phpDocumentor/.github/.github/workflows/static-analysis.yml@v0.9"
with:
php-extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, fileinfo, pcntl, posix"
composer-root-version: "2.x-dev"
unit-tests:
name: "Unit test"
uses: "phpDocumentor/.github/.github/workflows/continuous-integration.yml@v0.9"
with:
composer-root-version: "2.x-dev"
php-versions: "['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']"
================================================
FILE: .gitignore
================================================
# IDE Shizzle; it is recommended to use a global .gitignore for this but since this is an OSS project we want to make
# it easy to contribute
.idea
/nbproject/private/
.buildpath
.project
.settings
# Build folder and vendor folder are generated code; no need to version this
build/
temp/
tools/
vendor/
*.phar
# By default the phpunit.xml.dist is provided; you can override this using a local config file
phpunit.xml
.phpunit.result.cache
================================================
FILE: .yamllint.yaml
================================================
extends: "default"
ignore: |
.build/
.notes/
vendor/
rules:
braces:
max-spaces-inside-empty: 0
max-spaces-inside: 1
min-spaces-inside-empty: 0
min-spaces-inside: 1
brackets:
max-spaces-inside-empty: 0
max-spaces-inside: 0
min-spaces-inside-empty: 0
min-spaces-inside: 0
colons:
max-spaces-after: 1
max-spaces-before: 0
commas:
max-spaces-after: 1
max-spaces-before: 0
min-spaces-after: 1
comments:
ignore-shebangs: true
min-spaces-from-content: 1
require-starting-space: true
comments-indentation: "enable"
document-end:
present: false
document-start:
present: false
indentation:
check-multi-line-strings: false
indent-sequences: true
spaces: 2
empty-lines:
max-end: 0
max-start: 0
max: 1
empty-values:
forbid-in-block-mappings: true
forbid-in-flow-mappings: true
hyphens:
max-spaces-after: 2
key-duplicates: "enable"
key-ordering: "disable"
line-length: "disable"
new-line-at-end-of-file: "enable"
new-lines:
type: "unix"
octal-values:
forbid-implicit-octal: true
quoted-strings:
quote-type: "double"
trailing-spaces: "enable"
truthy:
allowed-values:
- "false"
- "true"
yaml-files:
- "*.yaml"
- "*.yml"
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2015 phpDocumentor
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: Makefile
================================================
.PHONY: help
help: ## Displays this list of targets with descriptions
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: code-style
code-style:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest -d memory_limit=1024M -s
.PHONY: fix-code-style
fix-code-style:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest phpcbf
.PHONY: static-code-analysis
static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan and vimeo/psalm
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpstan --configuration=phpstan.neon
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/psalm
.PHONY: test
test: test-unit ## Runs all test suites with phpunit/phpunit
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpunit
.PHONY: test-unit
test-unit: ## Runs unit tests with phpunit/phpunit
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpunit --testsuite=unit
.PHONY: dependency-analysis
dependency-analysis: vendor ## Runs a dependency analysis with maglnet/composer-require-checker
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 .phive/composer-require-checker check --config-file=/opt/project/composer-require-checker.json
vendor: composer.json composer.lock
composer validate --no-check-publish
composer install --no-interaction --no-progress
.PHONY: rector
rector: ## Refactor code using rector
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/rector process
.PHONY: pre-commit-test
pre-commit-test: fix-code-style test code-style static-code-analysis
================================================
FILE: README.md
================================================
[](https://opensource.org/licenses/MIT)

[](https://coveralls.io/github/phpDocumentor/ReflectionCommon?branch=master)
[](https://scrutinizer-ci.com/g/phpDocumentor/ReflectionCommon/?branch=master)
[](https://scrutinizer-ci.com/g/phpDocumentor/ReflectionCommon/?branch=master)
[](https://packagist.org/packages/phpDocumentor/Reflection-Common)
[](https://packagist.org/packages/phpDocumentor/Reflection-Common)
ReflectionCommon
================
================================================
FILE: composer.json
================================================
{
"name": "phpdocumentor/reflection-common",
"keywords": ["phpdoc", "phpDocumentor", "reflection", "static analysis", "FQSEN"],
"homepage": "https://www.phpdoc.org",
"description": "Common reflection classes used by phpdocumentor to reflect the code structure",
"license": "MIT",
"minimum-stability": "stable",
"authors": [
{
"name": "Jaap van Otterdijk",
"email": "opensource@ijaap.nl"
}
],
"require": {
"php": "^7.4 || ^8.0"
},
"autoload" : {
"psr-4" : {
"phpDocumentor\\Reflection\\": "src/"
}
},
"extra": {
"branch-alias": {
"dev-2.x": "2.x-dev"
}
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.8",
"vimeo/psalm": "^4.25"
},
"config": {
"platform": {
"php": "7.4.1"
}
}
}
================================================
FILE: phive.xml
================================================
================================================
FILE: phpcs.xml.dist
================================================
The coding standard for this library.
src
tests/unit
================================================
FILE: phpmd.xml.dist
================================================
40
================================================
FILE: phpstan.neon
================================================
parameters:
level: max
paths:
- src
- tests
================================================
FILE: phpunit.xml.dist
================================================
./tests/unit/
src
================================================
FILE: psalm.xml
================================================
================================================
FILE: src/Element.php
================================================
fqsen = $fqsen;
if (isset($matches[2])) {
$this->name = $matches[2];
} elseif ($fqsen === '\\') {
$this->name = '';
} else {
$matches = explode('\\', $fqsen);
$name = end($matches);
$this->name = trim($name, '()');
}
}
/**
* converts this class to string.
*/
public function __toString(): string
{
return $this->fqsen;
}
/**
* Returns the name of the element without path.
*/
public function getName(): string
{
return $this->name;
}
}
================================================
FILE: src/Location.php
================================================
lineNumber = $lineNumber;
$this->columnNumber = $columnNumber;
}
/**
* Returns the line number that is covered by this location.
*/
public function getLineNumber(): int
{
return $this->lineNumber;
}
/**
* Returns the column number (character position on a line) for this location object.
*/
public function getColumnNumber(): int
{
return $this->columnNumber;
}
}
================================================
FILE: src/Project.php
================================================
assertEquals($name, $instance->getName());
}
/**
* Data provider for ValidFormats tests. Contains a complete list from psr-5 draft.
*
* @return array>
*/
public function validFqsenProvider(): array
{
return [
['\\', ''],
['\My\Space', 'Space'],
['\My\Space\myFunction()', 'myFunction'],
['\My\Space\MY_CONSTANT', 'MY_CONSTANT'],
['\My\Space\MY_CONSTANT2', 'MY_CONSTANT2'],
['\My\Space\MyClass', 'MyClass'],
['\My\Space\MyInterface', 'MyInterface'],
['\My\Space\Option«T»', 'Option«T»'],
['\My\Space\MyTrait', 'MyTrait'],
['\My\Space\MyClass::myMethod()', 'myMethod'],
['\My\Space\MyClass::$my_property', 'my_property'],
['\My\Space\MyClass::MY_CONSTANT', 'MY_CONSTANT'],
];
}
/**
* @covers ::__construct
* @dataProvider invalidFqsenProvider
*/
public function testInValidFormats(string $fqsen): void
{
$this->expectException(InvalidArgumentException::class);
new Fqsen($fqsen);
}
/**
* Data provider for invalidFormats tests. Contains a complete list from psr-5 draft.
*
* @return array>
*/
public function invalidFqsenProvider(): array
{
return [
['\My\*'],
['\My\Space\.()'],
['My\Space'],
['1_function()'],
];
}
/**
* @covers ::__construct
* @covers ::__toString
*/
public function testToString(): void
{
$className = new Fqsen('\\phpDocumentor\\Application');
$this->assertEquals('\\phpDocumentor\\Application', (string) $className);
}
}