Skip to content
Snippets Groups Projects
Commit b4b40bed authored by David Prévot's avatar David Prévot
Browse files

New upstream version 6.0.0

parents 2e7e47f8 b7522496
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,9 @@ on:
name: "CI"
env:
COMPOSER_ROOT_VERSION: "6.0-dev"
permissions:
contents: read
......@@ -17,12 +20,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.3
coverage: none
- name: Run PHP-CS-Fixer
......@@ -35,12 +38,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.3
coverage: none
- name: Install dependencies with Composer
......@@ -58,13 +61,13 @@ jobs:
fail-fast: false
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
steps:
- name: "Checkout"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"
- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@v2"
......@@ -72,13 +75,6 @@ jobs:
php-version: "${{ matrix.php-version }}"
coverage: "pcov"
- name: "Cache dependencies installed with Composer"
uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}"
restore-keys: "php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"
- name: "Install dependencies with Composer"
run: "./tools/composer update --no-ansi --no-interaction --no-progress"
......
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="php-cs-fixer" version="^3.0" installed="3.14.3" location="./tools/php-cs-fixer" copy="true"/>
<phar name="psalm" version="^5.0" installed="5.6.0" location="./tools/psalm" copy="true"/>
<phar name="composer" version="^2.0.3" installed="2.5.1" location="./tools/composer" copy="true"/>
<phar name="php-cs-fixer" version="^3.0" installed="3.41.1" location="./tools/php-cs-fixer" copy="true"/>
<phar name="psalm" version="^5.0" installed="5.18.0" location="./tools/psalm" copy="true"/>
<phar name="composer" version="^2.0.3" installed="2.6.6" location="./tools/composer" copy="true"/>
</phive>
......@@ -25,6 +25,10 @@ $config->setFinder($finder)
'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',
],
......@@ -33,6 +37,7 @@ $config->setFinder($finder)
'blank_line_before_statement' => [
'statements' => [
'break',
'case',
'continue',
'declare',
'default',
......@@ -44,6 +49,7 @@ $config->setFinder($finder)
'if',
'include',
'include_once',
'phpdoc',
'require',
'require_once',
'return',
......@@ -52,15 +58,21 @@ $config->setFinder($finder)
'try',
'while',
'yield',
'yield_from',
],
],
'braces' => [
'position_after_anonymous_constructs' => 'next',
'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' => 'one',
'const' => 'none',
'method' => 'one',
'property' => 'only_if_meta'
]
......@@ -70,10 +82,13 @@ $config->setFinder($finder)
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'combine_nested_dirname' => true,
'compact_nullable_typehint' => 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,
......@@ -87,7 +102,6 @@ $config->setFinder($finder)
'fully_qualified_strict_types' => true,
'function_declaration' => true,
'function_to_constant' => true,
'function_typehint_space' => true,
'get_class_to_class_keyword' => true,
'global_namespace_import' => [
'import_classes' => true,
......@@ -99,9 +113,10 @@ $config->setFinder($finder)
'implode_call' => true,
'include' => true,
'increment_style' => [
'style' => PhpCsFixer\Fixer\Operator\IncrementStyleFixer::STYLE_POST,
'style' => 'post',
],
'indentation_type' => true,
'integer_literal_case' => true,
'is_null' => true,
'lambda_not_used_import' => true,
'line_ending' => true,
......@@ -115,6 +130,8 @@ $config->setFinder($finder)
'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,
......@@ -125,10 +142,10 @@ $config->setFinder($finder)
'@internal',
],
],
'native_function_type_declaration_casing' => true,
'new_with_braces' => [
'named_class' => false,
'native_type_declaration_casing' => true,
'new_with_parentheses' => [
'anonymous_class' => false,
'named_class' => false,
],
'no_alias_functions' => true,
'no_alias_language_construct_call' => true,
......@@ -136,7 +153,6 @@ $config->setFinder($finder)
'no_binary_string' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => true,
'no_break_comment' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
......@@ -148,13 +164,14 @@ $config->setFinder($finder)
'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_spaces_inside_parenthesis' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
......@@ -163,15 +180,17 @@ $config->setFinder($finder)
'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_curly_braces' => 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,
......@@ -179,6 +198,7 @@ $config->setFinder($finder)
'non_printable_character' => true,
'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
'octal_notation' => true,
'operator_linebreak' => [
'only_booleans' => true,
'position' => 'end',
......@@ -209,9 +229,9 @@ $config->setFinder($finder)
],
'ordered_imports' => [
'imports_order' => [
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CONST,
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_FUNCTION,
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CLASS,
'const',
'function',
'class',
]
],
'ordered_interfaces' => [
......@@ -219,6 +239,7 @@ $config->setFinder($finder)
'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',
......@@ -242,6 +263,7 @@ $config->setFinder($finder)
'uses',
],
],
'phpdoc_param_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
......@@ -249,7 +271,7 @@ $config->setFinder($finder)
'phpdoc_summary' => true,
'phpdoc_tag_casing' => true,
'phpdoc_tag_type' => true,
'phpdoc_to_comment' => true,
'phpdoc_to_comment' => false,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types' => ['groups' => ['simple', 'meta']],
......@@ -271,14 +293,20 @@ $config->setFinder($finder)
'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_after_construct' => 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,
......@@ -288,13 +316,18 @@ $config->setFinder($finder)
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline' => [
'elements' => [
'arrays'
'arguments',
'arrays',
'match',
]
],
'trim_array_spaces' => true,
'types_spaces' => [
'space' => 'none',
'type_declaration_spaces' => [
'elements' => [
'function',
],
],
'types_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'elements' => [
......@@ -307,4 +340,6 @@ $config->setFinder($finder)
'whitespace_after_comma_in_array' => true,
]);
$config->setCacheFile(__DIR__ . '/.php-cs-fixer.cache/' . sha1(@trim((string) @shell_exec('git rev-parse --abbrev-ref HEAD'))));
return $config;
......@@ -5,6 +5,8 @@
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
resolveFromConfigFile="false"
errorBaseline=".psalm/baseline.xml"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<projectFiles>
<directory name="src" />
......
......@@ -2,6 +2,12 @@
All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
## [6.0.0] - 2024-02-02
### Removed
* This component is no longer supported on PHP 8.1
## [5.0.0] - 2023-02-03
### Removed
......@@ -39,6 +45,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* Tests etc. are now ignored for archive exports
[6.0.0]: https://github.com/sebastianbergmann/recursion-context/compare/5.0...6.0.0
[5.0.0]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.5...5.0.0
[4.0.5]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.4...4.0.5
[4.0.4]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.3...4.0.4
......
BSD 3-Clause License
Copyright (c) 2002-2023, Sebastian Bergmann
Copyright (c) 2002-2024, Sebastian Bergmann
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
# Security Policy
This library is intended to be used in development environments only. For instance, it is used by the testing framework PHPUnit. There is no reason why this library should be installed on a webserver.
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.
**If you upload this library to a webserver then your deployment process is broken. On a more general note, if your `vendor` directory is publicly accessible on your webserver then your deployment process is also broken.**
**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**
## Security Contact Information
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.
After the above, if you still would like to report a security vulnerability, please email `sebastian@phpunit.de`.
......@@ -17,19 +17,23 @@
"email": "aharvey@php.net"
}
],
"support": {
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
"security": "https://github.com/sebastianbergmann/recursion-context/security/policy"
},
"prefer-stable": true,
"config": {
"platform": {
"php": "8.1.0"
"php": "8.2.0"
},
"optimize-autoloader": true,
"sort-packages": true
},
"require": {
"php": ">=8.1"
"php": ">=8.2"
},
"require-dev": {
"phpunit/phpunit": "^10.0"
"phpunit/phpunit": "^11.0"
},
"autoload": {
"classmap": [
......@@ -38,7 +42,7 @@
},
"extra": {
"branch-alias": {
"dev-main": "5.0-dev"
"dev-main": "6.0-dev"
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
......@@ -16,9 +16,9 @@
</testsuite>
</testsuites>
<coverage>
<source>
<include>
<directory suffix=".php">src</directory>
<directory>src</directory>
</include>
</coverage>
</source>
</phpunit>
......@@ -50,7 +50,7 @@ final class Context
*
* @param-out T $value
*/
public function add(object|array &$value): int|string|false
public function add(array|object &$value): false|int|string
{
if (is_array($value)) {
return $this->addArray($value);
......@@ -66,7 +66,7 @@ final class Context
*
* @param-out T $value
*/
public function contains(object|array &$value): int|string|false
public function contains(array|object &$value): false|int|string
{
if (is_array($value)) {
return $this->containsArray($value);
......@@ -123,14 +123,14 @@ final class Context
return spl_object_hash($object);
}
private function containsArray(array $array): int|false
private function containsArray(array $array): false|int
{
$end = array_slice($array, -2);
return isset($end[1]) && $end[1] === $this->objects ? $end[0] : false;
}
private function containsObject(object $value): string|false
private function containsObject(object $value): false|string
{
if ($this->objects->contains($value)) {
return spl_object_hash($value);
......
......@@ -47,7 +47,6 @@ final class ContextTest extends TestCase
$storage = new SplObjectStorage;
$storage->attach($obj2);
$storage->foo = $obj2;
return [
[$obj, spl_object_hash($obj)],
......@@ -68,10 +67,10 @@ final class ContextTest extends TestCase
#[DataProvider('valuesProvider')]
public function testAdd($value, $key): void
{
$this->assertEquals($key, $this->context->add($value));
$this->assertSame($key, $this->context->add($value));
// Test we get the same key on subsequent adds
$this->assertEquals($key, $this->context->add($value));
$this->assertSame($key, $this->context->add($value));
}
public function testAdd2(): void
......@@ -87,10 +86,10 @@ final class ContextTest extends TestCase
public function testContainsFound($value, $key): void
{
$this->context->add($value);
$this->assertEquals($key, $this->context->contains($value));
$this->assertSame($key, $this->context->contains($value));
// Test we get the same key on subsequent calls
$this->assertEquals($key, $this->context->contains($value));
$this->assertSame($key, $this->context->contains($value));
}
#[DataProvider('valuesProvider')]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment