Repository: sebastianbergmann/code-unit-reverse-lookup
Branch: main
Commit: 5cf245ed8605
Files: 25
Total size: 22.4 MB
Directory structure:
gitextract_e2lv2no2/
├── .gitattributes
├── .github/
│ ├── CODE_OF_CONDUCT.md
│ ├── CONTRIBUTING.md
│ ├── FUNDING.yml
│ └── workflows/
│ ├── ci.yml
│ └── release.yaml
├── .gitignore
├── .phive/
│ └── phars.xml
├── .php-cs-fixer.dist.php
├── ChangeLog.md
├── LICENSE
├── README.md
├── SECURITY.md
├── build/
│ └── scripts/
│ └── extract-release-notes.php
├── build.xml
├── composer.json
├── phpstan.neon
├── phpunit.xml
├── src/
│ └── Wizard.php
├── tests/
│ ├── WizardTest.php
│ └── _fixture/
│ ├── Bar.php
│ └── Foo.php
└── tools/
├── composer
├── php-cs-fixer
└── phpstan
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
/.gitattributes export-ignore
/.gitignore export-ignore
/.github export-ignore
/.phive export-ignore
/build export-ignore
/.php-cs-fixer.dist.php export-ignore
/build.xml export-ignore
/phpstan.neon export-ignore
/phpunit.xml export-ignore
/tests export-ignore
/tools export-ignore
/tools/* binary
*.php diff=php
================================================
FILE: .github/CODE_OF_CONDUCT.md
================================================
# Contributor Code of Conduct
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic
addresses, without explicit permission
* Other unethical or unprofessional conduct
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project maintainer at sebastian@phpunit.de. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Maintainers are obligated to maintain confidentiality with regard to the reporter of an incident.
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.3.0, available at [https://contributor-covenant.org/version/1/3/0/][version]
[homepage]: https://contributor-covenant.org
[version]: https://contributor-covenant.org/version/1/3/0/
================================================
FILE: .github/CONTRIBUTING.md
================================================
# Contributing to `sebastian/code-unit-reverse-lookup`
## Welcome!
We look forward to your contributions! Here are some examples how you can contribute:
* [Report a bug](https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues/new)
* [Send a pull request to fix a bug](https://github.com/sebastianbergmann/code-unit-reverse-lookup/pulls)
## We have a Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
## Any contributions you make will be under the BSD-3-Clause License
When you submit code changes, your submissions are understood to be under the same [BSD-3-Clause License](https://github.com/sebastianbergmann/code-unit-reverse-lookup/blob/main/LICENSE) that covers the project. By contributing to this project, you agree that your contributions will be licensed under its BSD-3-Clause License.
### Do Not Violate Copyright
Only submit a pull request with your own original code. Do NOT submit a pull request containing code which you have largely copied from
another project, unless you wrote the respective code yourself.
Open Source does not mean that copyright does not apply. Copyright infringements will not be tolerated and can lead to you being banned from this project and repository.
### Do Not Submit AI-Generated Pull Requests
The same goes for (largely) AI-generated pull requests. These are not welcome as they will be based on copyrighted code from others
without accreditation and without taking the license of the original code into account, let alone getting permission
for the use of the code or for re-licensing.
Aside from that, the experience is that AI-generated pull requests will be incorrect 100% of the time and cost reviewers too much time.
Submitting a (largely) AI-generated pull request will lead to you being banned from this project and repository.
## Write bug reports with detail, background, and sample code
[This is an example](https://github.com/sebastianbergmann/phpunit/issues/4376) of a bug report I wrote, and I think it's not too bad.
In your bug report, please provide the following:
* A quick summary and/or background
* Steps to reproduce
* Be specific!
* Give sample code if you can.
* What you expected would happen
* What actually happens
* Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
Please do not report a bug for a version of this library that is no longer supported. Please do not report a bug if you are using a version of PHP that is not supported by the version of this library you are using.
The library that is developed in this repository was either extracted from [PHPUnit](https://github.com/sebastianbergmann/phpunit) or developed specifically as a dependency for PHPUnit. Support for this library follows the [support for the version of PHPUnit that uses a specific version of this library](https://phpunit.de/supported-versions.html).
Please post code and output as text ([using proper markup](https://guides.github.com/features/mastering-markdown/)). Do not post screenshots of code or output.
## Workflow for Pull Requests
1. Fork the repository.
2. Create your branch from `main` if you plan to implement new functionality or change existing code significantly; create your branch from the oldest branch that is affected by the bug if you plan to fix a bug.
3. Implement your change and add tests for it.
4. Ensure the test suite passes.
5. Ensure the code complies with our coding guidelines (see below).
6. Send that pull request!
Please make sure you have [set up your username and email address](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) for use with Git. Strings such as `silly nick name <root@localhost>` look really stupid in the commit history of a project.
We encourage you to [sign your Git commits with your GPG key](https://docs.github.com/en/github/authenticating-to-github/signing-commits).
Pull requests for bug fixes must be made for the oldest branch that is supported (see above). Pull requests for new features must be based on the `main` branch.
We are trying to keep backwards compatibility breaks to an absolute minimum. Please take this into account when proposing changes.
Due to time constraints, we are not always able to respond as quickly as we would like. Please do not take delays personal and feel free to remind us if you feel that we forgot to respond.
## Development
This project uses [PHPUnit](https://phpunit.de/) for testing:
```shell
./vendor/bin/phpunit
```
This project uses [PHPStan](https://phpstan.org/) for static analysis:
```shell
./tools/phpstan
```
This project uses [PHP-CS-Fixer](https://cs.symfony.com/) to enforce coding guidelines:
```shell
./tools/php-cs-fixer fix
```
The commands shown above require an autoloader script at `vendor/autoload.php`. This can be generated like so:
```shell
./tools/composer dump-autoload
```
Please understand that we will not accept a pull request when its changes violate this project's coding guidelines or break the test suite.
## Low Maintenance Project
This library was developed specifically as a dependency for [PHPUnit](https://github.com/sebastianbergmann/phpunit).
Starting with PHPUnit 12, PHPUnit no longer depends on this library.
This library is now a low maintenance project.
Bugs that have an impact on [versions of PHPUnit that still receive bug fixes](https://phpunit.de/supported-versions.html) and still depend on this library will be fixed in this library.
Aside from the above, no further development of this library is planned.
================================================
FILE: .github/FUNDING.yml
================================================
github: sebastianbergmann
liberapay: sebastianbergmann
thanks_dev: u/gh/sebastianbergmann
tidelift: "packagist/sebastian/code-unit-reverse-lookup"
================================================
FILE: .github/workflows/ci.yml
================================================
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
on:
- pull_request
- push
name: CI
env:
COMPOSER_ROOT_VERSION: 4.0.x-dev
permissions:
contents: read
jobs:
coding-guidelines:
name: Coding Guidelines
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none
- name: Run PHP-CS-Fixer
run: ./tools/php-cs-fixer fix --dry-run --show-progress=dots --using-cache=no --verbose
static-analysis:
name: Static Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none
- name: Install dependencies with Composer
run: ./tools/composer update --no-interaction --no-ansi --no-progress
- name: Run PHPStan
run: ./tools/phpstan analyse --no-progress --error-format=github
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version:
- 8.2
- 8.3
- 8.4
- 8.5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: xdebug
- name: Install dependencies with Composer
run: ./tools/composer update --no-ansi --no-interaction --no-progress
- name: Run tests with PHPUnit
run: ./vendor/bin/phpunit --log-junit test-results.xml --coverage-clover=code-coverage.xml
- name: Upload test results to Codecov.io
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
disable_search: true
files: ./test-results.xml
- name: Upload code coverage data to Codecov.io
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
disable_search: true
files: ./code-coverage.xml
================================================
FILE: .github/workflows/release.yaml
================================================
# https://docs.github.com/en/actions
on:
push:
tags:
- "**"
name: Release
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none
extensions: none
tools: none
- name: Determine tag
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Parse ChangeLog
run: build/scripts/extract-release-notes.php ${{ env.RELEASE_TAG }} > release-notes.md
- name: Create release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.RELEASE_TAG }}
name: sebastian/code-unit-reverse-lookup ${{ env.RELEASE_TAG }}
bodyFile: release-notes.md
================================================
FILE: .gitignore
================================================
/.idea
/.php-cs-fixer.php
/.php-cs-fixer.cache
/.phpunit.cache
/composer.lock
/vendor
================================================
FILE: .phive/phars.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="php-cs-fixer" version="^3.64" installed="3.64.0" location="./tools/php-cs-fixer" copy="true"/>
<phar name="composer" version="^2.8" installed="2.8.2" location="./tools/composer" copy="true"/>
<phar name="phpstan" version="^2.0" installed="2.0.1" location="./tools/phpstan" copy="true"/>
</phive>
================================================
FILE: .php-cs-fixer.dist.php
================================================
<?php declare(strict_types=1);
$header = <<<'EOF'
This file is part of sebastian/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.
EOF;
$finder = PhpCsFixer\Finder::create()
->files()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
;
$config = new PhpCsFixer\Config;
$config->setFinder($finder)
->setRiskyAllowed(true)
->setRules([
'align_multiline_comment' => true,
'array_indentation' => true,
'array_push' => true,
'array_syntax' => ['syntax' => 'short'],
'backtick_to_shell_exec' => true,
'binary_operator_spaces' => [
'operators' => [
'*=' => 'align_single_space_minimal',
'+=' => 'align_single_space_minimal',
'-=' => 'align_single_space_minimal',
'/=' => 'align_single_space_minimal',
'=' => 'align_single_space_minimal',
'=>' => 'align_single_space_minimal',
],
],
'blank_line_after_namespace' => true,
'blank_line_before_statement' => [
'statements' => [
'break',
'case',
'continue',
'declare',
'default',
'do',
'exit',
'for',
'foreach',
'goto',
'if',
'include',
'include_once',
'phpdoc',
'require',
'require_once',
'return',
'switch',
'throw',
'try',
'while',
'yield',
'yield_from',
],
],
'blank_lines_before_namespace' => [
'max_line_breaks' => 1,
'min_line_breaks' => 0,
],
'braces_position' => [
'anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end',
'anonymous_functions_opening_brace' => 'next_line_unless_newline_at_signature_end',
],
'cast_spaces' => true,
'class_attributes_separation' => [
'elements' => [
'const' => 'none',
'method' => 'one',
'property' => 'only_if_meta'
]
],
'class_definition' => true,
'clean_namespace' => true,
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'combine_nested_dirname' => true,
'compact_nullable_type_declaration' => true,
'concat_space' => ['spacing' => 'one'],
'constant_case' => true,
'control_structure_braces' => true,
'control_structure_continuation_position' => true,
'declare_equal_normalize' => ['space' => 'none'],
'declare_parentheses' => true,
'declare_strict_types' => true,
'dir_constant' => true,
'echo_tag_syntax' => true,
'elseif' => true,
'encoding' => true,
'ereg_to_preg' => true,
'explicit_indirect_variable' => true,
'explicit_string_variable' => true,
'fopen_flag_order' => true,
'full_opening_tag' => true,
'fully_qualified_strict_types' => ['import_symbols' => true],
'function_declaration' => true,
'function_to_constant' => true,
'get_class_to_class_keyword' => true,
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
'header_comment' => ['header' => $header, 'separate' => 'none'],
'heredoc_to_nowdoc' => true,
'implode_call' => true,
'include' => true,
'increment_style' => [
'style' => 'post',
],
'indentation_type' => true,
'integer_literal_case' => true,
'is_null' => true,
'lambda_not_used_import' => true,
'line_ending' => true,
'list_syntax' => ['syntax' => 'short'],
'logical_operators' => true,
'lowercase_cast' => true,
'lowercase_keywords' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'magic_method_casing' => true,
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
],
'method_chaining_indentation' => true,
'modernize_strpos' => true,
'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => true,
'native_constant_invocation' => true,
'native_function_casing' => false,
'native_function_invocation' => [
'include' => [
'@internal',
],
],
'native_type_declaration_casing' => true,
'new_with_parentheses' => [
'anonymous_class' => false,
'named_class' => false,
],
'no_alias_functions' => true,
'no_alias_language_construct_call' => true,
'no_alternative_syntax' => true,
'no_binary_string' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_break_comment' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => [
'tokens' => [
'attribute',
'break',
'case',
'continue',
'curly_brace_block',
'default',
'extra',
'parenthesis_brace_block',
'return',
'square_brace_block',
'switch',
'throw',
'use',
],
],
'no_homoglyph_names' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => ['use' => 'print'],
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiple_statements_per_line' => true,
'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_space_around_double_colon' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
],
'no_trailing_comma_in_singleline' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_trailing_whitespace_in_string' => true,
'no_unneeded_braces' => true,
'no_unneeded_control_parentheses' => true,
'no_unneeded_final_method' => true,
'no_unneeded_import_alias' => true,
'no_unreachable_default_argument_value' => true,
'no_unset_cast' => true,
'no_unset_on_property' => true,
'no_unused_imports' => true,
'no_useless_concat_operator' => true,
'no_useless_else' => true,
'no_useless_nullsafe_operator' => true,
'no_useless_return' => true,
'no_useless_sprintf' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'non_printable_character' => true,
'normalize_index_brace' => true,
'nullable_type_declaration_for_default_null_value' => true,
'object_operator_without_whitespace' => true,
'octal_notation' => true,
'operator_linebreak' => [
'only_booleans' => true,
'position' => 'end',
],
'ordered_class_elements' => [
'order' => [
'use_trait',
'constant_public',
'constant_protected',
'constant_private',
'property_public_static',
'property_protected_static',
'property_private_static',
'property_public',
'property_protected',
'property_private',
'method_public_static',
'construct',
'destruct',
'magic',
'phpunit',
'method_public',
'method_protected',
'method_private',
'method_protected_static',
'method_private_static',
],
],
'ordered_imports' => [
'imports_order' => [
'const',
'function',
'class',
]
],
'ordered_interfaces' => [
'direction' => 'ascend',
'order' => 'alpha',
],
'ordered_traits' => true,
'ordered_types' => true,
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_test_case_static_method_calls' => [
'call_type' => 'this',
],
'phpdoc_add_missing_param_annotation' => false,
'phpdoc_align' => true,
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag_normalizer' => true,
'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_order' => true,
'phpdoc_order_by_value' => [
'annotations' => [
'covers',
'dataProvider',
'throws',
'uses',
],
],
'phpdoc_param_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'phpdoc_tag_casing' => true,
'phpdoc_tag_type' => true,
'phpdoc_to_comment' => false,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types' => ['groups' => ['simple', 'meta']],
'phpdoc_types_order' => true,
'phpdoc_var_annotation_correct_order' => true,
'phpdoc_var_without_name' => true,
'pow_to_exponentiation' => true,
'protected_to_private' => true,
'return_assignment' => true,
'return_type_declaration' => ['space_before' => 'none'],
'self_accessor' => true,
'self_static_accessor' => true,
'semicolon_after_instruction' => true,
'set_type_to_cast' => true,
'short_scalar_cast' => true,
'simple_to_complex_string_variable' => true,
'simplified_null_return' => false,
'single_blank_line_at_eof' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_spacing' => true,
'single_quote' => true,
'single_space_around_construct' => true,
'single_trait_insert_per_statement' => true,
'space_after_semicolon' => true,
'spaces_inside_parentheses' => [
'space' => 'none',
],
'standardize_increment' => true,
'standardize_not_equals' => true,
'statement_indentation' => true,
'static_lambda' => true,
'strict_param' => true,
'string_length_to_empty'=> true,
'string_line_ending' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'switch_continue_to_break' => true,
'ternary_operator_spaces' => true,
'ternary_to_elvis_operator' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline' => [
'elements' => [
'arguments',
'arrays',
'match',
]
],
'trim_array_spaces' => true,
'type_declaration_spaces' => [
'elements' => [
'function',
],
],
'types_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'elements' => [
'const',
'method',
'property',
],
],
'void_return' => true,
'whitespace_after_comma_in_array' => true,
]);
$config->setCacheFile(__DIR__ . '/.php-cs-fixer.cache/' . json_decode((string) @file_get_contents('composer.json'), true)["extra"]["branch-alias"]["dev-main"] ?? 'unknown');
$config->setParallelConfig(\PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect());
return $config;
================================================
FILE: ChangeLog.md
================================================
# 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.
## [4.0.1] - 2024-07-03
### Changed
* This project now uses PHPStan instead of Psalm for static analysis
## [4.0.0] - 2024-02-02
### Removed
* This component is no longer supported on PHP 8.1
## [3.0.0] - 2023-02-03
### Removed
* This component is no longer supported on PHP 7.3, PHP 7.4, and PHP 8.0
## [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
[4.0.1]: https://github.com/sebastianbergmann/code-unit-reverse-lookup/compare/4.0.0...4.0.1
[4.0.0]: https://github.com/sebastianbergmann/code-unit-reverse-lookup/compare/3.0...4.0.0
[3.0.0]: https://github.com/sebastianbergmann/code-unit-reverse-lookup/compare/2.0.3...3.0.0
[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
================================================
FILE: LICENSE
================================================
BSD 3-Clause License
Copyright (c) 2016-2025, Sebastian Bergmann
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. 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.
3. Neither the name of the copyright holder nor the names of its
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 HOLDER 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.
================================================
FILE: README.md
================================================
[](https://unmaintained.tech/)
[](https://packagist.org/packages/sebastian/code-unit-reverse-lookup)
[](https://github.com/sebastianbergmann/code-unit-reverse-lookup/actions)
[](https://codecov.io/gh/sebastianbergmann/code-unit-reverse-lookup)
# sebastian/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
```
Please note that this is now a [low maintenance project](https://github.com/sebastianbergmann/code-unit-reverse-lookup/blob/main/.github/CONTRIBUTING.md#low-maintenance-project).
================================================
FILE: SECURITY.md
================================================
# Security Policy
If you believe you have found a security vulnerability in the library that is developed in this repository, please report it to us through coordinated disclosure.
**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**
Instead, please email `sebastian@phpunit.de`.
Please include as much of the information listed below as you can to help us better understand and resolve the issue:
* The type of issue
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue
This information will help us triage your report more quickly.
## Web Context
The library that is developed in this repository was either extracted from [PHPUnit](https://github.com/sebastianbergmann/phpunit) or developed specifically as a dependency for PHPUnit.
The library is developed with a focus on development environments and the command-line. No specific testing or hardening with regard to using the library in an HTTP or web context or with untrusted input data is performed. The library might also contain functionality that intentionally exposes internal application data for debugging purposes.
If the library is used in a web application, the application developer is responsible for filtering inputs or escaping outputs as necessary and for verifying that the used functionality is safe for use within the intended context.
Vulnerabilities specific to the use outside a development context will be fixed as applicable, provided that the fix does not have an averse effect on the primary use case for development purposes.
================================================
FILE: build/scripts/extract-release-notes.php
================================================
#!/usr/bin/env php
<?php declare(strict_types=1);
if ($argc !== 2) {
print $argv[0] . ' <tag>' . PHP_EOL;
exit(1);
}
$version = $argv[1];
$file = __DIR__ . '/../../ChangeLog.md';
if (!is_file($file) || !is_readable($file)) {
print $file . ' cannot be read' . PHP_EOL;
exit(1);
}
$buffer = '';
$append = false;
foreach (file($file) as $line) {
if (str_starts_with($line, '## [' . $version . ']')) {
$append = true;
continue;
}
if ($append && (str_starts_with($line, '## ') || str_starts_with($line, '['))) {
break;
}
if ($append) {
$buffer .= $line;
}
}
$buffer = trim($buffer);
if ($buffer === '') {
print 'Unable to extract release notes' . PHP_EOL;
exit(1);
}
print $buffer . PHP_EOL;
================================================
FILE: build.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project name="code-unit-reverse-lookup" default="setup">
<target name="setup" depends="clean,install-dependencies"/>
<target name="clean" description="Cleanup build artifacts">
<delete dir="${basedir}/vendor"/>
<delete file="${basedir}/composer.lock"/>
</target>
<target name="install-dependencies" depends="clean" description="Install dependencies with Composer">
<exec executable="${basedir}/tools/composer" taskname="composer">
<arg value="update"/>
<arg value="--no-interaction"/>
<arg value="--no-progress"/>
<arg value="--no-ansi"/>
</exec>
</target>
<target name="update-tools">
<exec executable="phive" taskname="phive">
<arg value="--no-progress"/>
<arg value="update"/>
<arg value="--force-accept-unsigned"/>
</exec>
</target>
</project>
================================================
FILE: composer.json
================================================
{
"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"
}
],
"support": {
"issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues",
"security": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/security/policy"
},
"config": {
"platform": {
"php": "8.2.0"
},
"optimize-autoloader": true,
"sort-packages": true
},
"prefer-stable": true,
"require": {
"php": ">=8.2"
},
"require-dev": {
"phpunit/phpunit": "^11.3"
},
"autoload": {
"classmap": [
"src/"
]
},
"extra": {
"branch-alias": {
"dev-main": "4.0-dev"
}
}
}
================================================
FILE: phpstan.neon
================================================
parameters:
level: 10
paths:
- src
- tests
================================================
FILE: phpunit.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
shortenArraysForExportThreshold="10"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
displayDetailsOnPhpunitDeprecations="true"
failOnPhpunitDeprecation="true"
failOnRisky="true"
failOnWarning="true"
colors="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
================================================
FILE: src/Wizard.php
================================================
<?php declare(strict_types=1);
/*
* This file is part of sebastian/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 function array_merge;
use function assert;
use function class_exists;
use function get_declared_classes;
use function get_declared_traits;
use function get_defined_functions;
use function is_int;
use function is_string;
use function range;
use function trait_exists;
use ReflectionClass;
use ReflectionFunction;
use ReflectionMethod;
final class Wizard
{
/**
* @var array<string, array<int, string>>
*/
private array $lookupTable = [];
/**
* @var array<class-string, true>
*/
private array $processedClasses = [];
/**
* @var array<string, true>
*/
private array $processedFunctions = [];
public function lookup(string $filename, int $lineNumber): string
{
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();
foreach (array_merge($classes, $traits) as $classOrTrait) {
assert(class_exists($classOrTrait) || trait_exists($classOrTrait));
if (isset($this->processedClasses[$classOrTrait])) {
continue;
}
foreach ((new ReflectionClass($classOrTrait))->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(ReflectionFunction|ReflectionMethod $functionOrMethod): void
{
if ($functionOrMethod->isInternal()) {
return;
}
$name = $functionOrMethod->getName();
if ($functionOrMethod instanceof ReflectionMethod) {
$name = $functionOrMethod->getDeclaringClass()->getName() . '::' . $name;
}
$fileName = $functionOrMethod->getFileName();
assert(is_string($fileName));
if (!isset($this->lookupTable[$fileName])) {
$this->lookupTable[$fileName] = [];
}
$startLine = $functionOrMethod->getStartLine();
$endLine = $functionOrMethod->getEndLine();
assert(is_int($startLine));
assert(is_int($endLine));
assert($endLine >= $startLine);
foreach (range($startLine, $endLine) as $line) {
$this->lookupTable[$fileName][$line] = $name;
}
}
}
================================================
FILE: tests/WizardTest.php
================================================
<?php declare(strict_types=1);
/*
* This file is part of sebastian/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\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;
#[CoversClass(Wizard::class)]
final class WizardTest extends TestCase
{
private Wizard $wizard;
protected function setUp(): void
{
$this->wizard = new Wizard;
}
public function testMethodCanBeLookedUp(): Wizard
{
require __DIR__ . '/_fixture/Foo.php';
$this->assertEquals(
'Foo::method',
$this->wizard->lookup(
__DIR__ . '/_fixture/Foo.php',
12,
),
);
return $this->wizard;
}
#[Depends('testMethodCanBeLookedUp')]
public function testMethodCanBeLookedUp2(Wizard $wizard): void
{
require __DIR__ . '/_fixture/Bar.php';
$this->assertEquals(
'Bar::method',
$wizard->lookup(
__DIR__ . '/_fixture/Bar.php',
12,
),
);
}
public function testReturnsFilenameAndLineNumberAsStringWhenNotInCodeUnit(): void
{
$this->assertEquals(
'file.php:1',
$this->wizard->lookup('file.php', 1),
);
}
}
================================================
FILE: tests/_fixture/Bar.php
================================================
<?php declare(strict_types=1);
/*
* This file is part of sebastian/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.
*/
class Bar
{
public function method(): void
{
// ...
}
}
================================================
FILE: tests/_fixture/Foo.php
================================================
<?php declare(strict_types=1);
/*
* This file is part of sebastian/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.
*/
class Foo
{
public function method(): void
{
// ...
}
}
================================================
FILE: tools/phpstan
================================================
[File too large to display: 22.4 MB]
gitextract_e2lv2no2/
├── .gitattributes
├── .github/
│ ├── CODE_OF_CONDUCT.md
│ ├── CONTRIBUTING.md
│ ├── FUNDING.yml
│ └── workflows/
│ ├── ci.yml
│ └── release.yaml
├── .gitignore
├── .phive/
│ └── phars.xml
├── .php-cs-fixer.dist.php
├── ChangeLog.md
├── LICENSE
├── README.md
├── SECURITY.md
├── build/
│ └── scripts/
│ └── extract-release-notes.php
├── build.xml
├── composer.json
├── phpstan.neon
├── phpunit.xml
├── src/
│ └── Wizard.php
├── tests/
│ ├── WizardTest.php
│ └── _fixture/
│ ├── Bar.php
│ └── Foo.php
└── tools/
├── composer
├── php-cs-fixer
└── phpstan
SYMBOL INDEX (15 symbols across 4 files)
FILE: src/Wizard.php
class Wizard (line 26) | final class Wizard
method lookup (line 43) | public function lookup(string $filename, int $lineNumber): string
method updateLookupTable (line 56) | private function updateLookupTable(): void
method processClassesAndTraits (line 62) | private function processClassesAndTraits(): void
method processFunctions (line 82) | private function processFunctions(): void
method processFunctionOrMethod (line 95) | private function processFunctionOrMethod(ReflectionFunction|Reflection...
FILE: tests/WizardTest.php
class WizardTest (line 16) | #[CoversClass(Wizard::class)]
method setUp (line 21) | protected function setUp(): void
method testMethodCanBeLookedUp (line 26) | public function testMethodCanBeLookedUp(): Wizard
method testMethodCanBeLookedUp2 (line 41) | #[Depends('testMethodCanBeLookedUp')]
method testReturnsFilenameAndLineNumberAsStringWhenNotInCodeUnit (line 55) | public function testReturnsFilenameAndLineNumberAsStringWhenNotInCodeU...
FILE: tests/_fixture/Bar.php
class Bar (line 10) | class Bar
method method (line 12) | public function method(): void
FILE: tests/_fixture/Foo.php
class Foo (line 10) | class Foo
method method (line 12) | public function method(): void
Condensed preview — 25 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (44K chars).
[
{
"path": ".gitattributes",
"chars": 465,
"preview": "/.gitattributes export-ignore\n/.gitignore export-ignore\n/.github export-ignore\n/.phiv"
},
{
"path": ".github/CODE_OF_CONDUCT.md",
"chars": 2394,
"preview": "# Contributor Code of Conduct\n\nAs contributors and maintainers of this project, and in the interest of fostering an open"
},
{
"path": ".github/CONTRIBUTING.md",
"chars": 5694,
"preview": "# Contributing to `sebastian/code-unit-reverse-lookup`\n\n## Welcome!\n\nWe look forward to your contributions! Here are som"
},
{
"path": ".github/FUNDING.yml",
"chars": 147,
"preview": "github: sebastianbergmann\nliberapay: sebastianbergmann\nthanks_dev: u/gh/sebastianbergmann\ntidelift: \"packagist/sebastian"
},
{
"path": ".github/workflows/ci.yml",
"chars": 2290,
"preview": "# https://help.github.com/en/categories/automating-your-workflow-with-github-actions\n\non:\n - pull_request\n - push\n\nnam"
},
{
"path": ".github/workflows/release.yaml",
"chars": 965,
"preview": "# https://docs.github.com/en/actions\n\non:\n push:\n tags:\n - \"**\"\n\nname: Release\n\njobs:\n release:\n name: Rele"
},
{
"path": ".gitignore",
"chars": 86,
"preview": "/.idea\n/.php-cs-fixer.php\n/.php-cs-fixer.cache\n/.phpunit.cache\n/composer.lock\n/vendor\n"
},
{
"path": ".phive/phars.xml",
"chars": 391,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phive xmlns=\"https://phar.io/phive\">\n <phar name=\"php-cs-fixer\" version=\"^3.64\""
},
{
"path": ".php-cs-fixer.dist.php",
"chars": 13066,
"preview": "<?php declare(strict_types=1);\n$header = <<<'EOF'\nThis file is part of sebastian/code-unit-reverse-lookup.\n\n(c) Sebastia"
},
{
"path": "ChangeLog.md",
"chars": 1601,
"preview": "# Change Log\n\nAll notable changes to `sebastianbergmann/code-unit-reverse-lookup` are documented in this file using the "
},
{
"path": "LICENSE",
"chars": 1531,
"preview": "BSD 3-Clause License\n\nCopyright (c) 2016-2025, Sebastian Bergmann\nAll rights reserved.\n\nRedistribution and use in source"
},
{
"path": "README.md",
"chars": 1295,
"preview": "[](https://unmaintained.tech/)\n[;\nif ($argc !== 2) {\n print $argv[0] . ' <tag>' . PHP_EOL;\n\n exit("
},
{
"path": "build.xml",
"chars": 952,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project name=\"code-unit-reverse-lookup\" default=\"setup\">\n <target name=\"setup"
},
{
"path": "composer.json",
"chars": 1047,
"preview": "{\n \"name\": \"sebastian/code-unit-reverse-lookup\",\n \"description\": \"Looks up which function or method a line of code"
},
{
"path": "phpstan.neon",
"chars": 67,
"preview": "parameters:\n level: 10\n paths:\n - src\n - tests\n"
},
{
"path": "phpunit.xml",
"chars": 984,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:noNam"
},
{
"path": "src/Wizard.php",
"chars": 3469,
"preview": "<?php declare(strict_types=1);\n/*\n * This file is part of sebastian/code-unit-reverse-lookup.\n *\n * (c) Sebastian Bergma"
},
{
"path": "tests/WizardTest.php",
"chars": 1534,
"preview": "<?php declare(strict_types=1);\n/*\n * This file is part of sebastian/code-unit-reverse-lookup.\n *\n * (c) Sebastian Bergma"
},
{
"path": "tests/_fixture/Bar.php",
"chars": 356,
"preview": "<?php declare(strict_types=1);\n/*\n * This file is part of sebastian/code-unit-reverse-lookup.\n *\n * (c) Sebastian Bergma"
},
{
"path": "tests/_fixture/Foo.php",
"chars": 356,
"preview": "<?php declare(strict_types=1);\n/*\n * This file is part of sebastian/code-unit-reverse-lookup.\n *\n * (c) Sebastian Bergma"
}
]
// ... and 3 more files (download for full content)
About this extraction
This page contains the full source code of the sebastianbergmann/code-unit-reverse-lookup GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 25 files (22.4 MB), approximately 10.3k tokens, and a symbol index with 15 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.