summaryrefslogtreecommitdiff
path: root/vendor/sebastian/code-unit-reverse-lookup
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sebastian/code-unit-reverse-lookup')
-rw-r--r--vendor/sebastian/code-unit-reverse-lookup/ChangeLog.md38
-rw-r--r--vendor/sebastian/code-unit-reverse-lookup/LICENSE33
-rw-r--r--vendor/sebastian/code-unit-reverse-lookup/README.md20
-rw-r--r--vendor/sebastian/code-unit-reverse-lookup/composer.json36
-rw-r--r--vendor/sebastian/code-unit-reverse-lookup/src/Wizard.php125
5 files changed, 252 insertions, 0 deletions
diff --git a/vendor/sebastian/code-unit-reverse-lookup/ChangeLog.md b/vendor/sebastian/code-unit-reverse-lookup/ChangeLog.md
new file mode 100644
index 000000000..43a5db90d
--- /dev/null
+++ b/vendor/sebastian/code-unit-reverse-lookup/ChangeLog.md
@@ -0,0 +1,38 @@
+# 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.
+
+## [2.0.3] - 2020-09-28
+
+### Changed
+
+* Changed PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3`
+
+## [2.0.2] - 2020-06-26
+
+### Added
+
+* This component is now supported on PHP 8
+
+## [2.0.1] - 2020-06-15
+
+### Changed
+
+* Tests etc. are now ignored for archive exports
+
+## 2.0.0 - 2020-02-07
+
+### Removed
+
+* This component is no longer supported on PHP 5.6, PHP 7.0, PHP 7.1, and PHP 7.2
+
+## 1.0.0 - 2016-02-13
+
+### Added
+
+* Initial release
+
+[2.0.3]: https://github.com/sebastianbergmann/code-unit-reverse-lookup/compare/2.0.2...2.0.3
+[2.0.2]: https://github.com/sebastianbergmann/code-unit-reverse-lookup/compare/2.0.1...2.0.2
+[2.0.1]: https://github.com/sebastianbergmann/code-unit-reverse-lookup/compare/2.0.0...2.0.1
+[2.0.0]: https://github.com/sebastianbergmann/code-unit-reverse-lookup/compare/1.0.0...2.0.0
diff --git a/vendor/sebastian/code-unit-reverse-lookup/LICENSE b/vendor/sebastian/code-unit-reverse-lookup/LICENSE
new file mode 100644
index 000000000..dc4bf7019
--- /dev/null
+++ b/vendor/sebastian/code-unit-reverse-lookup/LICENSE
@@ -0,0 +1,33 @@
+code-unit-reverse-lookup
+
+Copyright (c) 2016-2020, Sebastian Bergmann <[email protected]>.
+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.
diff --git a/vendor/sebastian/code-unit-reverse-lookup/README.md b/vendor/sebastian/code-unit-reverse-lookup/README.md
new file mode 100644
index 000000000..1c0ca235e
--- /dev/null
+++ b/vendor/sebastian/code-unit-reverse-lookup/README.md
@@ -0,0 +1,20 @@
+# sebastian/code-unit-reverse-lookup
+
+[![CI Status](https://github.com/sebastianbergmann/code-unit-reverse-lookup/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/code-unit-reverse-lookup/actions)
+[![Type Coverage](https://shepherd.dev/github/sebastianbergmann/code-unit-reverse-lookup/coverage.svg)](https://shepherd.dev/github/sebastianbergmann/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
+```
diff --git a/vendor/sebastian/code-unit-reverse-lookup/composer.json b/vendor/sebastian/code-unit-reverse-lookup/composer.json
new file mode 100644
index 000000000..cff96167a
--- /dev/null
+++ b/vendor/sebastian/code-unit-reverse-lookup/composer.json
@@ -0,0 +1,36 @@
+{
+ "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": "[email protected]"
+ }
+ ],
+ "prefer-stable": true,
+ "config": {
+ "platform": {
+ "php": "7.3.0"
+ },
+ "optimize-autoloader": true,
+ "sort-packages": true
+ },
+ "require": {
+ "php": ">=7.3"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.3"
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0-dev"
+ }
+ }
+}
diff --git a/vendor/sebastian/code-unit-reverse-lookup/src/Wizard.php b/vendor/sebastian/code-unit-reverse-lookup/src/Wizard.php
new file mode 100644
index 000000000..35de53981
--- /dev/null
+++ b/vendor/sebastian/code-unit-reverse-lookup/src/Wizard.php
@@ -0,0 +1,125 @@
+<?php declare(strict_types=1);
+/*
+ * This file is part of sebastian/code-unit-reverse-lookup.
+ *
+ * (c) Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace SebastianBergmann\CodeUnitReverseLookup;
+
+use function array_merge;
+use function assert;
+use function get_declared_classes;
+use function get_declared_traits;
+use function get_defined_functions;
+use function is_array;
+use function range;
+use ReflectionClass;
+use ReflectionFunction;
+use ReflectionFunctionAbstract;
+use ReflectionMethod;
+
+/**
+ * @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];
+ }
+
+ return $filename . ':' . $lineNumber;
+ }
+
+ private function updateLookupTable(): void
+ {
+ $this->processClassesAndTraits();
+ $this->processFunctions();
+ }
+
+ private function processClassesAndTraits(): void
+ {
+ $classes = get_declared_classes();
+ $traits = get_declared_traits();
+
+ assert(is_array($classes));
+ assert(is_array($traits));
+
+ foreach (array_merge($classes, $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(): void
+ {
+ foreach (get_defined_functions()['user'] as $function) {
+ if (isset($this->processedFunctions[$function])) {
+ continue;
+ }
+
+ $this->processFunctionOrMethod(new ReflectionFunction($function));
+
+ $this->processedFunctions[$function] = true;
+ }
+ }
+
+ private function processFunctionOrMethod(ReflectionFunctionAbstract $functionOrMethod): void
+ {
+ 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;
+ }
+ }
+}