Skip to content

bump thecodingmachine safe to 3#1

Merged
NicolasMugnier merged 16 commits intomainfrom
bump-thecodingmachine-safe-to-3
Apr 28, 2026
Merged

bump thecodingmachine safe to 3#1
NicolasMugnier merged 16 commits intomainfrom
bump-thecodingmachine-safe-to-3

Conversation

@NicolasMugnier
Copy link
Copy Markdown

  • chore(dependencies): updates
  • chore(phpstan): fix errors
  • fix(tests): update snapshots and fix setOptions unknown key handling
  • fix(tests): fix MT_RAND_PHP and float modulo PHP 8.4 deprecations
  • fix(ArrayFaker): re-index array after array_unique to avoid associative keys
  • fix(deps): patch cebe/php-openapi for PHP 8.4 implicit nullable deprecations

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates project dependencies (notably thecodingmachine/safe v3 and cebe/php-openapi v1.8) and adjusts faker/test logic to address PHPStan findings and PHP 8.4 deprecations, with snapshots refreshed accordingly.

Changes:

  • Bump runtime + dev dependencies and add a composer patch to silence PHP 8.4 implicit-nullable deprecations in cebe/php-openapi.
  • Refine faker generation logic (enum/format/pattern checks, array uniqueItems reindexing, safer schema/property handling).
  • Update tests and snapshots for RNG/behavior changes and PHP 8.4 deprecations.

Reviewed changes

Copilot reviewed 74 out of 74 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
composer.json Bumps dependencies; adds composer-patches configuration for cebe/php-openapi PHP 8.4 deprecations.
patches/cebe-php-openapi-php84-nullable.patch Patch to add explicit nullable type hints to avoid PHP 8.4 implicit-nullable deprecations.
src/OpenAPIFaker.php Tightens setOptions() to only apply known keys via array_intersect_key + match.
src/SchemaFaker/ArrayFaker.php Reindexes array_unique() output via array_values(); adjusts uniqueness comparison behavior.
src/SchemaFaker/BooleanFaker.php Treats empty enums as “no enum” for generation decisions.
src/SchemaFaker/NumberFaker.php Treats empty enums as “no enum” for generation decisions.
src/SchemaFaker/ObjectFaker.php Skips non-Schema properties before applying readOnly/writeOnly filtering.
src/SchemaFaker/SchemaFaker.php Uses !empty($schema->properties) when deciding object generation fallback.
src/SchemaFaker/StringFaker.php Switches enum/format/pattern checks from !== null to !empty().
src/Utils/RegexUtils.php Uses Safe\preg_replace_callback and removes unnecessary null-coalescing on $regex.
tests/Integration/E2ETest.php Avoids risky tests via addToAssertionCount; adds instanceof Schema guard before schema access.
tests/Integration/OpenAPIFakerTest.php Replaces instance assertions with addToAssertionCount; reformats @testWith; removes duplicate assertion.
tests/Unit/UnitTestCase.php Adjusts seeding to avoid MT_RAND_PHP usage.
tests/Unit/SchemaFaker/ArrayFakerTest.php Drops Safe\sort, removes MT_RAND_PHP usage in seeding, updates unique-element test.
tests/Unit/SchemaFaker/NumberFakerTest.php Avoids float % deprecation by casting before modulo in a test.
tests/Unit/SchemaFaker/ObjectFakerTest.php Removes redundant assertIsArray assertions; snapshots updated.
tests/Unit/SchemaFaker/StaticObjectFakerTest.php Removes redundant assertIsArray assertions.
tests/Unit/SchemaFaker/StringFakerTest.php Uses sprintf instead of Safe\sprintf.
tests/Unit/SchemaFaker/__snapshots__/ArrayFakerTest__it_can_generate_items__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ArrayFakerTest__it_can_handle_both_min_and_max_items__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ArrayFakerTest__it_can_handle_max_items__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ArrayFakerTest__it_can_handle_min_items__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ArrayFakerTest__it_can_override_both_minimum_and_maximum_items_with_options__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ArrayFakerTest__it_can_override_maximum_items_with_option__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ArrayFakerTest__it_can_override_minimum_if_its_greater_than_maximum__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ArrayFakerTest__it_can_override_minimum_items_with_option__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ArrayFakerTest__it_handles_nested_arrays__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ArrayFakerTest__it_will_not_override_maximum_items_with_option_if_option_is_greater__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ArrayFakerTest__it_will_not_override_minimum_items_with_option_if_option_is_smaller__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ArrayFakerTest__it_will_use_minimum_plus_15_as_max_items_if_its_not_given__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/NumberFakerTest__it_can_generate_a_integer__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/NumberFakerTest__it_can_generate_a_number__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/NumberFakerTest__it_can_generate_elements_from_enum__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/NumberFakerTest__it_can_handle_both_minimum_and_maximum_keyword__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/NumberFakerTest__it_can_handle_exclusive_maximum_keyword__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/NumberFakerTest__it_can_handle_exclusive_minimum_keyword__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/NumberFakerTest__it_can_handle_integer_int32_format__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/NumberFakerTest__it_can_handle_integer_int64_format__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/NumberFakerTest__it_can_handle_maximum_keyword__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/NumberFakerTest__it_can_handle_minimum_keyword__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/NumberFakerTest__it_can_handle_number_double_format__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/NumberFakerTest__it_can_handle_number_float_format__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ObjectFakerTest__it_can_fake_all_properties_if_always_fake_optionals_option_is_set__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ObjectFakerTest__it_can_generate_nested_objects__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ObjectFakerTest__it_can_generate_simple_object__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ObjectFakerTest__it_does_not_inlcude_readonly_properties_when_type_is_request__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ObjectFakerTest__it_does_not_inlcude_writeonly_properties_when_type_is_response__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ObjectFakerTest__it_includes_required_properties_all_the_time__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/RequestFakerTest__it_will_mock_the_request__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/ResponseFakerTest__it_will_mock_the_response__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/SchemaFakerTest__allof_merge__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/SchemaFakerTest__another_merge_test__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/SchemaFakerTest__it_can_choose_one_schema_from_one_of__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/SchemaFakerTest__it_can_merge_all_of_with_other_properties__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/SchemaFakerTest__it_can_merge_schemas_from_all_of__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/SchemaFakerTest__it_can_recursively_merge_of_constraints__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/SchemaFakerTest__it_will_merge_all_of_with_existing_schema__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/SchemaFakerTest__it_will_merge_one_of_with_existing_schema__1.json Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_can_generate_elements_from_enum__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_can_generate_single_string__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_can_handle_binary_format__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_can_handle_byte_format__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_can_handle_email_format__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_can_handle_hostname_format__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_can_handle_ipv4_format__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_can_handle_ipv6_format__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_can_handle_max_length__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_can_handle_min_length__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_can_handle_password_format__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_can_handle_patterns__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_can_handle_uri_format__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_can_handle_uuid_format__1.txt Snapshot refresh for updated RNG/output.
tests/Unit/SchemaFaker/__snapshots__/StringFakerTest__it_will_return_a_string_if_unknown_format_is_given__1.txt Snapshot refresh for updated RNG/output.
Comments suppressed due to low confidence (2)

src/SchemaFaker/ArrayFaker.php:18

  • These imports/constants are now unused (is_array, SORT_STRING) after switching to SORT_REGULAR. Removing them will avoid unused-import noise in static analysis.
use function is_array;

use const SORT_REGULAR;
use const SORT_STRING;

src/SchemaFaker/ArrayFaker.php:63

  • array_unique() cannot increase the number of elements, so count($uniqueData) > count($fakeData) is unreachable. If the intent is to skip work when nothing changed, compare with === (no duplicates) or just remove this branch and only reindex when duplicates were removed.
            $uniqueData = array_unique($fakeData, SORT_REGULAR);

            if (count($uniqueData) > count($fakeData)) {
                continue;
            }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/SchemaFaker/StringFaker.php Outdated
Comment thread tests/Unit/SchemaFaker/ArrayFakerTest.php Outdated
Comment thread tests/Integration/OpenAPIFakerTest.php Outdated
Comment thread tests/Integration/OpenAPIFakerTest.php
Comment thread tests/Integration/OpenAPIFakerTest.php Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 73 out of 73 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (2)

src/SchemaFaker/ArrayFaker.php:18

  • ArrayFaker no longer uses is_array() or SORT_STRING, so the corresponding imports/constants are now unused. Please remove them (or reintroduce usage) to avoid dead imports and keep static analysis clean.
use function count;
use function is_array;

use const SORT_REGULAR;
use const SORT_STRING;

src/SchemaFaker/ArrayFaker.php:63

  • This uniqueness check is logically impossible: count($uniqueData) can never be greater than count($fakeData) right after array_unique(). The condition is effectively dead code; it can be removed, or (if the intent was to detect duplicates) changed to the correct comparison.
            $uniqueData = array_unique($fakeData, SORT_REGULAR);

            if (count($uniqueData) > count($fakeData)) {
                continue;
            }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Unit/SchemaFaker/NumberFakerTest.php
Comment thread src/SchemaFaker/StringFaker.php Outdated
Comment thread src/SchemaFaker/NumberFaker.php Outdated
Comment thread src/SchemaFaker/BooleanFaker.php Outdated
Comment thread src/OpenAPIFaker.php Outdated
NicolasMugnier and others added 12 commits April 27, 2026 16:51
Use array_intersect_key to filter unknown keys before dispatching
options, preventing UnhandledMatchError at runtime.
Update FakerPHP email snapshots to match new generation format.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace MT_RAND_PHP (deprecated in PHP 8.4) with the default MT_RAND_MT19937
algorithm in UnitTestCase and ArrayFakerTest.
Replace implicit float-to-int cast in modulo operation with explicit (int) cast.
Update all test snapshots to match the new RNG sequence.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ve keys

array_unique() preserves original keys, which can leave gaps in integer
keys when a duplicate is removed (e.g. [0,1,2,3,4,6,7,8,9] missing 5).
League\OpenAPIValidation treats any array with non-sequential keys as an
associative array (object), causing validation to fail for schemas with
uniqueItems: true (e.g. TweetWithheld.country_codes).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…cations

cebe/php-openapi 1.8.0 (latest, effectively abandoned) uses the old
`SomeType $param = null` syntax instead of `?SomeType $param = null`
across 9 methods in 6 files. PHP 8.4 emits Deprecated notices for each,
causing PHPUnit to mark integration tests as risky (unexpected output).

Also bumps cebe/php-openapi to ^1.8 and spatie/phpunit-snapshot-assertions
to ^5.3 to remove remaining PHP 8.4 deprecations.

Adds cweagans/composer-patches with a single patch file applied
automatically on every composer install.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@NicolasMugnier NicolasMugnier force-pushed the bump-thecodingmachine-safe-to-3 branch from 9fe1831 to 1302143 Compare April 27, 2026 14:52
@NicolasMugnier NicolasMugnier force-pushed the bump-thecodingmachine-safe-to-3 branch from 3e8ae92 to 82b8a87 Compare April 27, 2026 15:14
@NicolasMugnier NicolasMugnier force-pushed the bump-thecodingmachine-safe-to-3 branch from e26650b to b4eb74a Compare April 28, 2026 09:22
@NicolasMugnier NicolasMugnier requested a review from Dzov April 28, 2026 09:25
@NicolasMugnier NicolasMugnier merged commit fdb5457 into main Apr 28, 2026
3 checks passed
@NicolasMugnier NicolasMugnier deleted the bump-thecodingmachine-safe-to-3 branch April 28, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants