commitall
This commit is contained in:
4
vendor/sebastian/code-unit-reverse-lookup/.gitignore
vendored
Normal file
4
vendor/sebastian/code-unit-reverse-lookup/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/.idea
|
||||
/composer.lock
|
||||
/vendor
|
||||
|
67
vendor/sebastian/code-unit-reverse-lookup/.php_cs
vendored
Normal file
67
vendor/sebastian/code-unit-reverse-lookup/.php_cs
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
$finder = Symfony\CS\Finder\DefaultFinder::create()
|
||||
->files()
|
||||
->in('src')
|
||||
->in('tests')
|
||||
->name('*.php');
|
||||
|
||||
return Symfony\CS\Config\Config::create()
|
||||
->level(\Symfony\CS\FixerInterface::NONE_LEVEL)
|
||||
->fixers(
|
||||
array(
|
||||
'align_double_arrow',
|
||||
'align_equals',
|
||||
'braces',
|
||||
'concat_with_spaces',
|
||||
'duplicate_semicolon',
|
||||
'elseif',
|
||||
'empty_return',
|
||||
'encoding',
|
||||
'eof_ending',
|
||||
'extra_empty_lines',
|
||||
'function_call_space',
|
||||
'function_declaration',
|
||||
'indentation',
|
||||
'join_function',
|
||||
'line_after_namespace',
|
||||
'linefeed',
|
||||
'list_commas',
|
||||
'lowercase_constants',
|
||||
'lowercase_keywords',
|
||||
'method_argument_space',
|
||||
'multiple_use',
|
||||
'namespace_no_leading_whitespace',
|
||||
'no_blank_lines_after_class_opening',
|
||||
'no_empty_lines_after_phpdocs',
|
||||
'parenthesis',
|
||||
'php_closing_tag',
|
||||
'phpdoc_indent',
|
||||
'phpdoc_no_access',
|
||||
'phpdoc_no_empty_return',
|
||||
'phpdoc_no_package',
|
||||
'phpdoc_params',
|
||||
'phpdoc_scalar',
|
||||
'phpdoc_separation',
|
||||
'phpdoc_to_comment',
|
||||
'phpdoc_trim',
|
||||
'phpdoc_types',
|
||||
'phpdoc_var_without_name',
|
||||
'remove_lines_between_uses',
|
||||
'return',
|
||||
'self_accessor',
|
||||
'short_array_syntax',
|
||||
'short_tag',
|
||||
'single_line_after_imports',
|
||||
'single_quote',
|
||||
'spaces_before_semicolon',
|
||||
'spaces_cast',
|
||||
'ternary_spaces',
|
||||
'trailing_spaces',
|
||||
'trim_array_spaces',
|
||||
'unused_use',
|
||||
'visibility',
|
||||
'whitespacy_lines'
|
||||
)
|
||||
)
|
||||
->finder($finder);
|
||||
|
25
vendor/sebastian/code-unit-reverse-lookup/.travis.yml
vendored
Normal file
25
vendor/sebastian/code-unit-reverse-lookup/.travis.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.0snapshot
|
||||
- 7.1
|
||||
- 7.1snapshot
|
||||
- master
|
||||
|
||||
sudo: false
|
||||
|
||||
before_install:
|
||||
- composer self-update
|
||||
- composer clear-cache
|
||||
|
||||
install:
|
||||
- travis_retry composer update --no-interaction --no-ansi --no-progress --no-suggest --optimize-autoloader --prefer-stable
|
||||
|
||||
script:
|
||||
- ./vendor/bin/phpunit
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
15
vendor/sebastian/code-unit-reverse-lookup/ChangeLog.md
vendored
Normal file
15
vendor/sebastian/code-unit-reverse-lookup/ChangeLog.md
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# Change Log
|
||||
|
||||
All notable changes to `sebastianbergmann/code-unit-reverse-lookup` are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
|
||||
|
||||
## [1.0.2] - 2020-11-30
|
||||
|
||||
### Changed
|
||||
|
||||
* Changed PHP version constraint in `composer.json` from `^5.6 || ^7.0` to `>=5.6`
|
||||
|
||||
## 1.0.0 - 2016-02-13
|
||||
|
||||
* Initial release
|
||||
|
||||
[1.0.2]: https://github.com/sebastianbergmann/code-unit-reverse-lookup/compare/1.0.1...1.0.2
|
33
vendor/sebastian/code-unit-reverse-lookup/LICENSE
vendored
Normal file
33
vendor/sebastian/code-unit-reverse-lookup/LICENSE
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
code-unit-reverse-lookup
|
||||
|
||||
Copyright (c) 2016-2017, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of Sebastian Bergmann nor the names of his
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
14
vendor/sebastian/code-unit-reverse-lookup/README.md
vendored
Normal file
14
vendor/sebastian/code-unit-reverse-lookup/README.md
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
# code-unit-reverse-lookup
|
||||
|
||||
Looks up which function or method a line of code belongs to.
|
||||
|
||||
## Installation
|
||||
|
||||
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
|
||||
|
||||
composer require sebastian/code-unit-reverse-lookup
|
||||
|
||||
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
|
||||
|
||||
composer require --dev sebastian/code-unit-reverse-lookup
|
||||
|
22
vendor/sebastian/code-unit-reverse-lookup/build.xml
vendored
Normal file
22
vendor/sebastian/code-unit-reverse-lookup/build.xml
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="code-unit-reverse-lookup" default="setup">
|
||||
<target name="setup" depends="clean,composer"/>
|
||||
|
||||
<target name="clean" description="Cleanup build artifacts">
|
||||
<delete dir="${basedir}/vendor"/>
|
||||
<delete file="${basedir}/composer.lock"/>
|
||||
</target>
|
||||
|
||||
<target name="composer" depends="clean" description="Install dependencies with Composer">
|
||||
<exec executable="composer" taskname="composer">
|
||||
<arg value="update"/>
|
||||
<arg value="--no-interaction"/>
|
||||
<arg value="--no-progress"/>
|
||||
<arg value="--no-ansi"/>
|
||||
<arg value="--no-suggest"/>
|
||||
<arg value="--optimize-autoloader"/>
|
||||
<arg value="--prefer-stable"/>
|
||||
</exec>
|
||||
</target>
|
||||
</project>
|
||||
|
28
vendor/sebastian/code-unit-reverse-lookup/composer.json
vendored
Normal file
28
vendor/sebastian/code-unit-reverse-lookup/composer.json
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "sebastian/code-unit-reverse-lookup",
|
||||
"description": "Looks up which function or method a line of code belongs to",
|
||||
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
|
||||
"license": "BSD-3-Clause",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.5"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
21
vendor/sebastian/code-unit-reverse-lookup/phpunit.xml
vendored
Normal file
21
vendor/sebastian/code-unit-reverse-lookup/phpunit.xml
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.4/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
beStrictAboutCoversAnnotation="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
beStrictAboutTestsThatDoNotTestAnything="true"
|
||||
beStrictAboutTodoAnnotatedTests="true"
|
||||
verbose="true">
|
||||
<testsuite>
|
||||
<directory suffix="Test.php">tests</directory>
|
||||
</testsuite>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
111
vendor/sebastian/code-unit-reverse-lookup/src/Wizard.php
vendored
Normal file
111
vendor/sebastian/code-unit-reverse-lookup/src/Wizard.php
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of code-unit-reverse-lookup.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\CodeUnitReverseLookup;
|
||||
|
||||
/**
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class Wizard
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $lookupTable = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $processedClasses = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $processedFunctions = [];
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @param int $lineNumber
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function lookup($filename, $lineNumber)
|
||||
{
|
||||
if (!isset($this->lookupTable[$filename][$lineNumber])) {
|
||||
$this->updateLookupTable();
|
||||
}
|
||||
|
||||
if (isset($this->lookupTable[$filename][$lineNumber])) {
|
||||
return $this->lookupTable[$filename][$lineNumber];
|
||||
} else {
|
||||
return $filename . ':' . $lineNumber;
|
||||
}
|
||||
}
|
||||
|
||||
private function updateLookupTable()
|
||||
{
|
||||
$this->processClassesAndTraits();
|
||||
$this->processFunctions();
|
||||
}
|
||||
|
||||
private function processClassesAndTraits()
|
||||
{
|
||||
foreach (array_merge(get_declared_classes(), get_declared_traits()) as $classOrTrait) {
|
||||
if (isset($this->processedClasses[$classOrTrait])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$reflector = new \ReflectionClass($classOrTrait);
|
||||
|
||||
foreach ($reflector->getMethods() as $method) {
|
||||
$this->processFunctionOrMethod($method);
|
||||
}
|
||||
|
||||
$this->processedClasses[$classOrTrait] = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function processFunctions()
|
||||
{
|
||||
foreach (get_defined_functions()['user'] as $function) {
|
||||
if (isset($this->processedFunctions[$function])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->processFunctionOrMethod(new \ReflectionFunction($function));
|
||||
|
||||
$this->processedFunctions[$function] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ReflectionFunctionAbstract $functionOrMethod
|
||||
*/
|
||||
private function processFunctionOrMethod(\ReflectionFunctionAbstract $functionOrMethod)
|
||||
{
|
||||
if ($functionOrMethod->isInternal()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$name = $functionOrMethod->getName();
|
||||
|
||||
if ($functionOrMethod instanceof \ReflectionMethod) {
|
||||
$name = $functionOrMethod->getDeclaringClass()->getName() . '::' . $name;
|
||||
}
|
||||
|
||||
if (!isset($this->lookupTable[$functionOrMethod->getFileName()])) {
|
||||
$this->lookupTable[$functionOrMethod->getFileName()] = [];
|
||||
}
|
||||
|
||||
foreach (range($functionOrMethod->getStartLine(), $functionOrMethod->getEndLine()) as $line) {
|
||||
$this->lookupTable[$functionOrMethod->getFileName()][$line] = $name;
|
||||
}
|
||||
}
|
||||
}
|
45
vendor/sebastian/code-unit-reverse-lookup/tests/WizardTest.php
vendored
Normal file
45
vendor/sebastian/code-unit-reverse-lookup/tests/WizardTest.php
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of code-unit-reverse-lookup.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\CodeUnitReverseLookup;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\CodeUnitReverseLookup\Wizard
|
||||
*/
|
||||
class WizardTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Wizard
|
||||
*/
|
||||
private $wizard;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->wizard = new Wizard;
|
||||
}
|
||||
|
||||
public function testMethodCanBeLookedUp()
|
||||
{
|
||||
$this->assertEquals(
|
||||
__METHOD__,
|
||||
$this->wizard->lookup(__FILE__, __LINE__)
|
||||
);
|
||||
}
|
||||
|
||||
public function testReturnsFilenameAndLineNumberAsStringWhenNotInCodeUnit()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'file.php:1',
|
||||
$this->wizard->lookup('file.php', 1)
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user