From 1f8cc1f2de1b393f3fc71dc50115c3d93428a5b9 Mon Sep 17 00:00:00 2001 From: Toon Verwerft Date: Wed, 14 Oct 2020 09:37:46 +0200 Subject: [PATCH 1/2] [CS] Add cs fixer config --- .github/workflows/coding-standards.yml | 3 ++ .php_cs.dist | 52 ++++++++++++++++++++++++++ composer.json | 13 +++++-- 3 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 .php_cs.dist diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index bca5c91d..b276a356 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -23,3 +23,6 @@ jobs: - name: "checking coding standards ( codesniffer )" run: "composer cs:check" + + - name: "checking coding standards ( php-cs-fixer )" + run: "composer cs-fixer:check" diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 00000000..7ddb7150 --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,52 @@ +setFinder( + \Symfony\Component\Finder\Finder::create() + ->in([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ) + ->setRiskyAllowed(true) + ->setRules([ + 'align_multiline_comment' => true, + 'array_indentation' => true, + 'declare_strict_types' => true, + // Currently it is not possible to mark all classes as final (exceptions etc.) + // We can run this fixer periodically on the tests folder only. + // 'final_class' => true, + 'global_namespace_import' => [ + 'import_classes' => true, + 'import_constants' => true, + 'import_functions' => true, + ], + 'list_syntax' => [ + 'syntax' => 'short', + ], + 'lowercase_constants' => true, + 'multiline_comment_opening_closing' => true, + 'native_function_casing' => true, + 'no_empty_phpdoc' => true, + 'no_leading_import_slash' => true, + 'no_superfluous_phpdoc_tags' => [ + 'allow_mixed' => true, + ], + 'no_unused_imports' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'ordered_imports' => [ + 'imports_order' => ['class', 'function', 'const'], + ], + 'ordered_interfaces' => true, + 'php_unit_test_annotation' => true, + 'php_unit_test_case_static_method_calls' => [ + 'call_type' => 'static', + ], + 'single_import_per_statement' => true, + 'single_trait_insert_per_statement' => true, + 'static_lambda' => true, + 'strict_comparison' => true, + 'strict_param' => true, + ]) +; diff --git a/composer.json b/composer.json index 5dfbc456..44e1eeec 100644 --- a/composer.json +++ b/composer.json @@ -12,16 +12,17 @@ "require": { "php": "^7.4", "ext-bcmath": "*", - "ext-mbstring": "*", "ext-json": "*", + "ext-mbstring": "*", "ext-sodium": "*" }, "require-dev": { - "vimeo/psalm": "dev-master", "phpunit/phpunit": "^9.0", "php-coveralls/php-coveralls": "^2.2", + "friendsofphp/php-cs-fixer": "^2.16", "roave/security-advisories": "dev-master", - "squizlabs/php_codesniffer": "^3.5" + "squizlabs/php_codesniffer": "^3.5", + "vimeo/psalm": "dev-master" }, "autoload": { "psr-4": { @@ -39,12 +40,15 @@ "scripts": { "cs:fix": "phpcbf", "cs:check": "phpcs", + "cs-fixer:fix": "php-cs-fixer fix", + "cs-fixer:check": "php-cs-fixer fix --dry-run", "type:check": "psalm", "type:coverage": "psalm --shepherd", "test:unit": "phpunit", "code:coverage": "php-coveralls -v", "security:analysis": "psalm --taint-analysis", "check": [ + "@cs-fixer:check", "@cs:check", "@type:check", "@security:analysis", @@ -52,6 +56,7 @@ ] }, "config": { - "process-timeout": 1200 + "process-timeout": 1200, + "sort-packages": true } } From 24bf7b9f720d6da473473b2ae5b3683ce62cb488 Mon Sep 17 00:00:00 2001 From: Toon Verwerft Date: Thu, 15 Oct 2020 10:18:03 +0200 Subject: [PATCH 2/2] [CS] Fixes based on added php-cs-fixer config --- src/Psl/Arr/contains_key.php | 4 +- src/Psl/Arr/drop.php | 1 - src/Psl/Arr/first_key.php | 4 +- src/Psl/Arr/group_by.php | 1 - src/Psl/Arr/keys.php | 4 +- src/Psl/Arr/sort.php | 1 - src/Psl/Arr/sort_by.php | 7 +- src/Psl/Arr/sort_by_key.php | 7 +- src/Psl/Arr/sort_with_keys.php | 7 +- src/Psl/Arr/sort_with_keys_by.php | 2 +- src/Psl/Arr/unique_by.php | 2 - src/Psl/Collection/MutableVectorInterface.php | 2 +- .../DataStructure/PriorityQueueInterface.php | 3 - src/Psl/DataStructure/QueueInterface.php | 2 +- src/Psl/DataStructure/StackInterface.php | 2 +- src/Psl/Env/get_vars.php | 2 - src/Psl/Env/set_current_dir.php | 1 - src/Psl/Env/temp_dir.php | 2 - src/Psl/Exception/ExceptionInterface.php | 4 +- src/Psl/Internal/internal_encoding.php | 4 +- src/Psl/Internal/is_encoding_valid.php | 5 - src/Psl/Internal/type.php | 2 - src/Psl/Iter/Iterator.php | 2 +- src/Psl/Iter/contains_key.php | 2 - src/Psl/Iter/count.php | 4 +- src/Psl/Iter/diff_by_key.php | 4 +- src/Psl/Iter/drop.php | 1 - src/Psl/Iter/filter_with_key.php | 2 +- src/Psl/Iter/first_key.php | 2 - src/Psl/Iter/product.php | 2 +- src/Psl/Iter/reduce_keys.php | 2 +- src/Psl/Iter/reduce_with_keys.php | 2 +- src/Psl/Iter/repeat.php | 1 - src/Psl/Iter/zip.php | 12 +- src/Psl/Math/max_by.php | 2 - src/Psl/Password/verify.php | 2 - src/Psl/PseudoRandom/float.php | 1 - src/Psl/Result/Failure.php | 1 - src/Psl/Str/Byte/words.php | 6 +- src/Psl/Str/convert_encoding.php | 5 +- src/Psl/Type/Type.php | 1 - tests/Psl/Arr/AtTest.php | 2 +- tests/Psl/Arr/ConcatTest.php | 3 +- tests/Psl/Arr/ContainsKeyTest.php | 2 +- tests/Psl/Arr/ContainsTest.php | 3 +- tests/Psl/Arr/CountTest.php | 5 +- tests/Psl/Arr/CountValuesTest.php | 3 +- tests/Psl/Arr/DropTest.php | 4 +- tests/Psl/Arr/DropWhileTest.php | 12 +- tests/Psl/Arr/EqualTest.php | 2 +- tests/Psl/Arr/FillTest.php | 2 +- tests/Psl/Arr/FilterKeysTest.php | 10 +- tests/Psl/Arr/FilterNullsTest.php | 12 +- tests/Psl/Arr/FilterTest.php | 10 +- tests/Psl/Arr/FilterWithKeyTest.php | 18 +- tests/Psl/Arr/FirstKeyTest.php | 2 +- tests/Psl/Arr/FirstTest.php | 2 +- tests/Psl/Arr/FirstxTest.php | 2 +- tests/Psl/Arr/FlattenTest.php | 5 +- tests/Psl/Arr/FlipTest.php | 4 +- tests/Psl/Arr/GroupByTest.php | 13 +- tests/Psl/Arr/IdxTest.php | 2 +- tests/Psl/Arr/KeysTest.php | 10 +- tests/Psl/Arr/LastKeyTest.php | 2 +- tests/Psl/Arr/LastTest.php | 2 +- tests/Psl/Arr/LastxTest.php | 2 +- tests/Psl/Arr/MapKeysTest.php | 12 +- tests/Psl/Arr/MapTest.php | 12 +- tests/Psl/Arr/MapWithKeyTest.php | 12 +- tests/Psl/Arr/MergeTest.php | 5 +- tests/Psl/Arr/PartitionTest.php | 14 +- tests/Psl/Arr/RandomTest.php | 2 +- tests/Psl/Arr/SelectKeysTest.php | 4 +- tests/Psl/Arr/ShuffleTest.php | 4 +- tests/Psl/Arr/SliceTest.php | 8 +- tests/Psl/Arr/SortByKeyTest.php | 6 +- tests/Psl/Arr/SortByTest.php | 19 +- tests/Psl/Arr/SortTest.php | 4 +- tests/Psl/Arr/SortWithKeysByTest.php | 19 +- tests/Psl/Arr/SortWithKeysTest.php | 6 +- tests/Psl/Arr/TakeTest.php | 4 +- tests/Psl/Arr/TakeWhileTest.php | 12 +- tests/Psl/Arr/UniqueByTest.php | 6 +- tests/Psl/Arr/UniqueTest.php | 2 +- tests/Psl/Arr/ValuesTest.php | 10 +- tests/Psl/Collection/AbstractMapTest.php | 390 +++++++++--------- tests/Psl/Collection/AbstractVectorTest.php | 390 +++++++++--------- tests/Psl/Collection/MutableMapTest.php | 50 +-- tests/Psl/Collection/MutableVectorTest.php | 54 +-- tests/Psl/DataStructure/PriorityQueueTest.php | 56 +-- tests/Psl/DataStructure/QueueTest.php | 46 +-- tests/Psl/DataStructure/StackTest.php | 30 +- tests/Psl/Env/ArgsTest.php | 2 +- tests/Psl/Env/CurrentDirTest.php | 6 +- tests/Psl/Env/CurrentExecTest.php | 2 +- tests/Psl/Env/GetVarTest.php | 6 +- tests/Psl/Env/GetVarsTest.php | 8 +- tests/Psl/Env/JoinPathsTest.php | 6 +- tests/Psl/Env/RemoveVarTest.php | 8 +- tests/Psl/Env/SplitPathsTest.php | 8 +- tests/Psl/Env/TempDirTest.php | 2 +- tests/Psl/Fun/AfterTest.php | 12 +- tests/Psl/Fun/IdentityTest.php | 2 +- tests/Psl/Fun/PipeTest.php | 16 +- tests/Psl/Fun/RethrowTest.php | 3 +- tests/Psl/Fun/WhenTest.php | 4 +- tests/Psl/InvariantTest.php | 2 +- tests/Psl/Iter/AllTest.php | 28 +- tests/Psl/Iter/AnyTest.php | 28 +- tests/Psl/Iter/ApplyTest.php | 6 +- tests/Psl/Iter/ChainTest.php | 2 +- tests/Psl/Iter/ChunkTest.php | 4 +- tests/Psl/Iter/ChunkWithKeysTest.php | 4 +- tests/Psl/Iter/ContainsKeyTest.php | 8 +- tests/Psl/Iter/ContainsTest.php | 8 +- tests/Psl/Iter/CountTest.php | 6 +- tests/Psl/Iter/DiffByKeyTest.php | 4 +- tests/Psl/Iter/DropTest.php | 4 +- tests/Psl/Iter/DropWhileTest.php | 32 +- tests/Psl/Iter/EnumerateTest.php | 4 +- tests/Psl/Iter/FilterKeysTest.php | 22 +- tests/Psl/Iter/FilterNullsTest.php | 26 +- tests/Psl/Iter/FilterTest.php | 22 +- tests/Psl/Iter/FilterWithKeyTest.php | 52 ++- tests/Psl/Iter/FirstKeyTest.php | 7 +- tests/Psl/Iter/FirstTest.php | 7 +- tests/Psl/Iter/FlattenTest.php | 4 +- tests/Psl/Iter/FlipTest.php | 2 +- tests/Psl/Iter/FromEntriesTest.php | 18 +- tests/Psl/Iter/FromKeysTest.php | 22 +- tests/Psl/Iter/IsEmptyTest.php | 6 +- tests/Psl/Iter/IteratorTest.php | 28 +- tests/Psl/Iter/KeysTest.php | 4 +- tests/Psl/Iter/LastKeyTest.php | 6 +- tests/Psl/Iter/LastTest.php | 7 +- tests/Psl/Iter/MapKeysTest.php | 16 +- tests/Psl/Iter/MapTest.php | 16 +- tests/Psl/Iter/MapWithKeyTest.php | 16 +- tests/Psl/Iter/MergeTest.php | 2 +- tests/Psl/Iter/ProductTest.php | 16 +- tests/Psl/Iter/PullTest.php | 8 +- tests/Psl/Iter/PullWithKeyTest.php | 8 +- tests/Psl/Iter/RandomTest.php | 6 +- tests/Psl/Iter/RangeTest.php | 12 +- tests/Psl/Iter/ReduceKeysTest.php | 8 +- tests/Psl/Iter/ReduceTest.php | 10 +- tests/Psl/Iter/ReduceWithKeysTest.php | 10 +- tests/Psl/Iter/ReductionsTest.php | 10 +- tests/Psl/Iter/ReindexTest.php | 6 +- tests/Psl/Iter/RepeatTest.php | 10 +- tests/Psl/Iter/ReproduceTest.php | 10 +- tests/Psl/Iter/ReverseTest.php | 6 +- tests/Psl/Iter/SearchTest.php | 16 +- tests/Psl/Iter/SliceTest.php | 8 +- tests/Psl/Iter/TakeTest.php | 4 +- tests/Psl/Iter/TakeWhileTest.php | 32 +- tests/Psl/Iter/ToArrayTest.php | 4 +- tests/Psl/Iter/ToArrayWithKeysTest.php | 4 +- tests/Psl/Iter/ToIteratorTest.php | 6 +- tests/Psl/Iter/ValuesTest.php | 2 +- tests/Psl/Iter/ZipTest.php | 4 +- tests/Psl/Json/DecodeTest.php | 4 +- tests/Psl/Json/EncodeTest.php | 8 +- tests/Psl/Json/TypedTest.php | 8 +- tests/Psl/Math/AbsTest.php | 4 +- tests/Psl/Math/BaseConvertTest.php | 4 +- tests/Psl/Math/CeilTest.php | 4 +- tests/Psl/Math/CosTest.php | 4 +- tests/Psl/Math/DivTest.php | 4 +- tests/Psl/Math/ExpTest.php | 4 +- tests/Psl/Math/FloorTest.php | 4 +- tests/Psl/Math/FromBaseTest.php | 4 +- tests/Psl/Math/LogTest.php | 4 +- tests/Psl/Math/MaxByTest.php | 51 ++- tests/Psl/Math/MaxTest.php | 5 +- tests/Psl/Math/MaxvaTest.php | 4 +- tests/Psl/Math/MeanTest.php | 5 +- tests/Psl/Math/MedianTest.php | 4 +- tests/Psl/Math/MinByTest.php | 49 ++- tests/Psl/Math/MinTest.php | 4 +- tests/Psl/Math/MinvaTest.php | 4 +- tests/Psl/Math/RoundTest.php | 4 +- tests/Psl/Math/SinTest.php | 4 +- tests/Psl/Math/SqrtTest.php | 4 +- tests/Psl/Math/SumFloatsTest.php | 14 +- tests/Psl/Math/SumTest.php | 4 +- tests/Psl/Math/TanTest.php | 4 +- tests/Psl/Math/ToBaseTest.php | 4 +- tests/Psl/Password/PasswordTest.php | 32 +- tests/Psl/PseudoRandom/FloatTest.php | 8 +- tests/Psl/PseudoRandom/IntTest.php | 20 +- tests/Psl/Result/FailureTest.php | 23 +- tests/Psl/Result/SuccessTest.php | 23 +- tests/Psl/Result/WrapTest.php | 19 +- tests/Psl/SecureRandom/BytesTest.php | 6 +- tests/Psl/SecureRandom/FloatTest.php | 8 +- tests/Psl/SecureRandom/IntTest.php | 20 +- tests/Psl/SecureRandom/StringTest.php | 12 +- tests/Psl/SequenceTest.php | 4 +- tests/Psl/Str/Byte/CapitalizeTest.php | 4 +- tests/Psl/Str/Byte/CapitalizeWordsTest.php | 4 +- tests/Psl/Str/Byte/ChrTest.php | 4 +- tests/Psl/Str/Byte/ChunkTest.php | 4 +- tests/Psl/Str/Byte/CompareCiTest.php | 8 +- tests/Psl/Str/Byte/CompareTest.php | 8 +- tests/Psl/Str/Byte/ContainsCiTest.php | 4 +- tests/Psl/Str/Byte/ContainsTest.php | 4 +- tests/Psl/Str/Byte/EndsWithCiTest.php | 4 +- tests/Psl/Str/Byte/EndsWithTest.php | 4 +- tests/Psl/Str/Byte/LengthTest.php | 4 +- tests/Psl/Str/Byte/LowercaseTest.php | 4 +- tests/Psl/Str/Byte/OrdTest.php | 4 +- tests/Psl/Str/Byte/PadLeftTest.php | 4 +- tests/Psl/Str/Byte/PadRightTest.php | 4 +- tests/Psl/Str/Byte/ReplaceCiTest.php | 4 +- tests/Psl/Str/Byte/ReplaceEveryCiTest.php | 4 +- tests/Psl/Str/Byte/ReplaceEveryTest.php | 4 +- tests/Psl/Str/Byte/ReplaceTest.php | 4 +- tests/Psl/Str/Byte/ReverseTest.php | 4 +- tests/Psl/Str/Byte/Rot13Test.php | 4 +- tests/Psl/Str/Byte/SearchCiTest.php | 4 +- tests/Psl/Str/Byte/SearchLastTest.php | 4 +- tests/Psl/Str/Byte/SearchTest.php | 4 +- tests/Psl/Str/Byte/ShuffleTest.php | 6 +- tests/Psl/Str/Byte/SliceTest.php | 4 +- tests/Psl/Str/Byte/SpliceTest.php | 4 +- tests/Psl/Str/Byte/SplitTest.php | 4 +- tests/Psl/Str/Byte/StartsWithCiTest.php | 4 +- tests/Psl/Str/Byte/StartsWithTest.php | 4 +- tests/Psl/Str/Byte/StripPrefixTest.php | 4 +- tests/Psl/Str/Byte/StripSuffixTest.php | 4 +- tests/Psl/Str/Byte/TrimLeftTest.php | 4 +- tests/Psl/Str/Byte/TrimRightTest.php | 4 +- tests/Psl/Str/Byte/TrimTest.php | 4 +- tests/Psl/Str/Byte/UppercaseTest.php | 4 +- tests/Psl/Str/Byte/WordsTest.php | 4 +- tests/Psl/Str/Byte/WrapTest.php | 5 +- tests/Psl/Str/CapitalizeTest.php | 4 +- tests/Psl/Str/CapitalizeWordsTest.php | 4 +- tests/Psl/Str/ChrTest.php | 4 +- tests/Psl/Str/ChunkTest.php | 4 +- tests/Psl/Str/ConcatTest.php | 8 +- tests/Psl/Str/ContainsCiTest.php | 4 +- tests/Psl/Str/ContainsTest.php | 4 +- tests/Psl/Str/ConvertEncodingTest.php | 2 +- tests/Psl/Str/DetectEncodingTest.php | 2 +- tests/Psl/Str/EndsWithCiTest.php | 6 +- tests/Psl/Str/EndsWithTest.php | 4 +- tests/Psl/Str/FoldTest.php | 4 +- tests/Psl/Str/FormatNumberTest.php | 4 +- tests/Psl/Str/FromCodePointsTest.php | 14 +- tests/Psl/Str/IsEmptyTest.php | 8 +- tests/Psl/Str/IsUTF8Test.php | 2 +- tests/Psl/Str/JoinTest.php | 8 +- tests/Psl/Str/LengthTest.php | 4 +- tests/Psl/Str/LevenshteinTest.php | 4 +- tests/Psl/Str/LowercaseTest.php | 4 +- tests/Psl/Str/MetaphoneTest.php | 4 +- tests/Psl/Str/OrdTest.php | 4 +- tests/Psl/Str/PadLeftTest.php | 4 +- tests/Psl/Str/PadRightTest.php | 4 +- tests/Psl/Str/RepeatTest.php | 4 +- tests/Psl/Str/ReplaceCiTest.php | 4 +- tests/Psl/Str/ReplaceEveryCiTest.php | 4 +- tests/Psl/Str/ReplaceEveryTest.php | 4 +- tests/Psl/Str/ReplaceTest.php | 4 +- tests/Psl/Str/SearchCiTest.php | 4 +- tests/Psl/Str/SearchLastCiTest.php | 4 +- tests/Psl/Str/SearchLastTest.php | 4 +- tests/Psl/Str/SearchTest.php | 4 +- tests/Psl/Str/SliceTest.php | 4 +- tests/Psl/Str/SpliceTest.php | 4 +- tests/Psl/Str/SplitTest.php | 4 +- tests/Psl/Str/StartsWithCiTest.php | 4 +- tests/Psl/Str/StartsWithTest.php | 4 +- tests/Psl/Str/StripPrefixTest.php | 4 +- tests/Psl/Str/StripSuffixTest.php | 4 +- tests/Psl/Str/ToIntTest.php | 4 +- tests/Psl/Str/TrimLeftTest.php | 4 +- tests/Psl/Str/TrimRightTest.php | 4 +- tests/Psl/Str/TrimTest.php | 4 +- tests/Psl/Str/TruncateTest.php | 4 +- tests/Psl/Str/UppercaseTest.php | 4 +- tests/Psl/Str/WidthTest.php | 4 +- tests/Psl/Str/WrapTest.php | 4 +- tests/Psl/Type/ArrayKeyTypeTest.php | 2 +- tests/Psl/Type/ArrayTypeTest.php | 8 +- tests/Psl/Type/BoolTypeTest.php | 2 +- .../Exception/TypeAssertExceptionTest.php | 6 +- .../Exception/TypeCoercionExceptionTest.php | 6 +- tests/Psl/Type/FloatTypeTest.php | 2 +- tests/Psl/Type/IntTypeTest.php | 2 +- tests/Psl/Type/IntersectionTypeTest.php | 9 +- tests/Psl/Type/IsArrayTest.php | 4 +- tests/Psl/Type/IsArraykeyTest.php | 20 +- tests/Psl/Type/IsCallableTest.php | 7 +- tests/Psl/Type/IsInstanceOfTest.php | 8 +- tests/Psl/Type/IsIntTest.php | 16 +- tests/Psl/Type/IsIterableTest.php | 6 +- tests/Psl/Type/IsNaNTest.php | 8 +- tests/Psl/Type/IsNumericTest.php | 23 +- tests/Psl/Type/IsScalarTest.php | 22 +- tests/Psl/Type/IsStringTest.php | 16 +- tests/Psl/Type/IterableTypeTest.php | 9 +- tests/Psl/Type/MixedTypeTest.php | 2 +- tests/Psl/Type/NullTypeTest.php | 2 +- tests/Psl/Type/NullableTypeTest.php | 2 +- tests/Psl/Type/NumTypeTest.php | 2 +- tests/Psl/Type/ObjectTypeTest.php | 2 +- tests/Psl/Type/ResourceSpecTest.php | 7 +- tests/Psl/Type/ResourceTypeTest.php | 4 +- tests/Psl/Type/StringTypeTest.php | 2 +- tests/Psl/Type/TypeTest.php | 11 +- tests/Psl/Type/UnionTypeTest.php | 2 +- 314 files changed, 1552 insertions(+), 1570 deletions(-) diff --git a/src/Psl/Arr/contains_key.php b/src/Psl/Arr/contains_key.php index d21c0009..66399ef0 100644 --- a/src/Psl/Arr/contains_key.php +++ b/src/Psl/Arr/contains_key.php @@ -4,6 +4,8 @@ namespace Psl\Arr; +use function array_key_exists; + /** * Returns true if the given array contains the key. * @@ -17,5 +19,5 @@ */ function contains_key(array $array, $key): bool { - return \array_key_exists($key, $array); + return array_key_exists($key, $array); } diff --git a/src/Psl/Arr/drop.php b/src/Psl/Arr/drop.php index c131073e..cd6992b8 100644 --- a/src/Psl/Arr/drop.php +++ b/src/Psl/Arr/drop.php @@ -4,7 +4,6 @@ namespace Psl\Arr; -use Generator; use Psl; /** diff --git a/src/Psl/Arr/first_key.php b/src/Psl/Arr/first_key.php index d6585544..3991c17b 100644 --- a/src/Psl/Arr/first_key.php +++ b/src/Psl/Arr/first_key.php @@ -4,6 +4,8 @@ namespace Psl\Arr; +use function array_key_first; + /** * Get the first key of an array, if the array is empty, null will be returned. * @@ -17,5 +19,5 @@ */ function first_key(array $array) { - return \array_key_first($array); + return array_key_first($array); } diff --git a/src/Psl/Arr/group_by.php b/src/Psl/Arr/group_by.php index bd660038..c780fabb 100644 --- a/src/Psl/Arr/group_by.php +++ b/src/Psl/Arr/group_by.php @@ -5,7 +5,6 @@ namespace Psl\Arr; use Psl; -use Psl\Str; use Psl\Type; /** diff --git a/src/Psl/Arr/keys.php b/src/Psl/Arr/keys.php index 25a8d3da..81325eac 100644 --- a/src/Psl/Arr/keys.php +++ b/src/Psl/Arr/keys.php @@ -4,6 +4,8 @@ namespace Psl\Arr; +use function array_keys; + /** * Return all the keys of an array. * @@ -18,5 +20,5 @@ */ function keys(array $arr): array { - return \array_keys($arr); + return array_keys($arr); } diff --git a/src/Psl/Arr/sort.php b/src/Psl/Arr/sort.php index 32d41fbf..9bca619b 100644 --- a/src/Psl/Arr/sort.php +++ b/src/Psl/Arr/sort.php @@ -19,7 +19,6 @@ * @psalm-param array $array * @psalm-param (callable(Tv, Tv): int)|null $comparator * - * @return array * * @psalm-return list */ diff --git a/src/Psl/Arr/sort_by.php b/src/Psl/Arr/sort_by.php index efcf16f5..9d20b0ce 100644 --- a/src/Psl/Arr/sort_by.php +++ b/src/Psl/Arr/sort_by.php @@ -4,6 +4,9 @@ namespace Psl\Arr; +use function asort; +use function uasort; + /** * Returns a new array sorted by some scalar property of each value of the given * iterable, which is computed by the given function. @@ -33,9 +36,9 @@ function sort_by(iterable $iterable, callable $scalar_func, ?callable $comparato } if (null !== $comparator) { - \uasort($order_by, $comparator); + uasort($order_by, $comparator); } else { - \asort($order_by); + asort($order_by); } $result = []; diff --git a/src/Psl/Arr/sort_by_key.php b/src/Psl/Arr/sort_by_key.php index 08722ae6..7475e487 100644 --- a/src/Psl/Arr/sort_by_key.php +++ b/src/Psl/Arr/sort_by_key.php @@ -4,6 +4,9 @@ namespace Psl\Arr; +use function ksort; +use function uksort; + /** * Returns a new array sorted by the keys of the given array. If the * optional comparator function isn't provided, the keys will be sorted in @@ -20,9 +23,9 @@ function sort_by_key(array $array, ?callable $comparator = null): array { if ($comparator) { - \uksort($array, $comparator); + uksort($array, $comparator); } else { - \ksort($array); + ksort($array); } return $array; diff --git a/src/Psl/Arr/sort_with_keys.php b/src/Psl/Arr/sort_with_keys.php index cec6ea42..dfab8dd3 100644 --- a/src/Psl/Arr/sort_with_keys.php +++ b/src/Psl/Arr/sort_with_keys.php @@ -4,6 +4,9 @@ namespace Psl\Arr; +use function asort; +use function uasort; + /** * Returns a new array sorted by the values of the given array. If the * optional comparator function isn't provided, the values will be sorted in @@ -20,9 +23,9 @@ function sort_with_keys(array $array, ?callable $comparator = null): array { if (null !== $comparator) { - \uasort($array, $comparator); + uasort($array, $comparator); } else { - \asort($array); + asort($array); } return $array; diff --git a/src/Psl/Arr/sort_with_keys_by.php b/src/Psl/Arr/sort_with_keys_by.php index 34e61a2f..c922410b 100644 --- a/src/Psl/Arr/sort_with_keys_by.php +++ b/src/Psl/Arr/sort_with_keys_by.php @@ -35,7 +35,7 @@ function sort_with_keys_by(iterable $iterable, callable $scalar_func, ?callable * @psalm-param array{0: Ts, 1: Tv} $a * @psalm-param array{0: Ts, 1: Tv} $b */ - fn ($a, $b): int => $comparator($a[0], $b[0]); + static fn ($a, $b): int => $comparator($a[0], $b[0]); /** * @psalm-var array $tuples diff --git a/src/Psl/Arr/unique_by.php b/src/Psl/Arr/unique_by.php index 3113cca3..73ca59cf 100644 --- a/src/Psl/Arr/unique_by.php +++ b/src/Psl/Arr/unique_by.php @@ -4,8 +4,6 @@ namespace Psl\Arr; -use Psl; - /** * Returns a new array in which each value appears exactly once, where the * value's uniqueness is determined by transforming it to a scalar via the diff --git a/src/Psl/Collection/MutableVectorInterface.php b/src/Psl/Collection/MutableVectorInterface.php index 6990acd5..a9fab7b9 100644 --- a/src/Psl/Collection/MutableVectorInterface.php +++ b/src/Psl/Collection/MutableVectorInterface.php @@ -10,7 +10,7 @@ * @extends VectorInterface * @extends MutableAccessibleCollectionInterface */ -interface MutableVectorInterface extends VectorInterface, MutableAccessibleCollectionInterface +interface MutableVectorInterface extends MutableAccessibleCollectionInterface, VectorInterface { /** * Get an array copy of the current vector. diff --git a/src/Psl/DataStructure/PriorityQueueInterface.php b/src/Psl/DataStructure/PriorityQueueInterface.php index 61decf2d..80443015 100644 --- a/src/Psl/DataStructure/PriorityQueueInterface.php +++ b/src/Psl/DataStructure/PriorityQueueInterface.php @@ -4,9 +4,6 @@ namespace Psl\DataStructure; -use Psl; -use Countable; - /** * @template T * diff --git a/src/Psl/DataStructure/QueueInterface.php b/src/Psl/DataStructure/QueueInterface.php index f7f85c1b..37118a3a 100644 --- a/src/Psl/DataStructure/QueueInterface.php +++ b/src/Psl/DataStructure/QueueInterface.php @@ -4,8 +4,8 @@ namespace Psl\DataStructure; -use Psl; use Countable; +use Psl; /** * An interface representing a queue data structure ( FIFO ). diff --git a/src/Psl/DataStructure/StackInterface.php b/src/Psl/DataStructure/StackInterface.php index 191fe335..83a02d44 100644 --- a/src/Psl/DataStructure/StackInterface.php +++ b/src/Psl/DataStructure/StackInterface.php @@ -4,8 +4,8 @@ namespace Psl\DataStructure; -use Psl; use Countable; +use Psl; /** * An interface representing a stack data structure ( LIFO ). diff --git a/src/Psl/Env/get_vars.php b/src/Psl/Env/get_vars.php index e471505f..db9c810d 100644 --- a/src/Psl/Env/get_vars.php +++ b/src/Psl/Env/get_vars.php @@ -4,8 +4,6 @@ namespace Psl\Env; -use Psl; - use function getenv; /** diff --git a/src/Psl/Env/set_current_dir.php b/src/Psl/Env/set_current_dir.php index 5c0b5a31..fa7442d2 100644 --- a/src/Psl/Env/set_current_dir.php +++ b/src/Psl/Env/set_current_dir.php @@ -11,7 +11,6 @@ /** * Changes the current working directory to the specified path. * - * @param string $directory * * @throws Psl\Exception\InvariantViolationException If the operation fails. */ diff --git a/src/Psl/Env/temp_dir.php b/src/Psl/Env/temp_dir.php index 82ecbb3a..34f12e86 100644 --- a/src/Psl/Env/temp_dir.php +++ b/src/Psl/Env/temp_dir.php @@ -4,8 +4,6 @@ namespace Psl\Env; -use Psl; - use function sys_get_temp_dir; /** diff --git a/src/Psl/Exception/ExceptionInterface.php b/src/Psl/Exception/ExceptionInterface.php index 9eef5816..fc0c0c8e 100644 --- a/src/Psl/Exception/ExceptionInterface.php +++ b/src/Psl/Exception/ExceptionInterface.php @@ -4,9 +4,11 @@ namespace Psl\Exception; +use Throwable; + /** * @internal */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface extends Throwable { } diff --git a/src/Psl/Internal/internal_encoding.php b/src/Psl/Internal/internal_encoding.php index bffc1b91..808fd479 100644 --- a/src/Psl/Internal/internal_encoding.php +++ b/src/Psl/Internal/internal_encoding.php @@ -5,12 +5,10 @@ namespace Psl\Internal; use Psl; -use Psl\Type; use Psl\Exception; +use Psl\Type; -use function in_array; use function mb_internal_encoding; -use function mb_list_encodings; /** * @psalm-pure diff --git a/src/Psl/Internal/is_encoding_valid.php b/src/Psl/Internal/is_encoding_valid.php index ccf4868a..863f9f85 100644 --- a/src/Psl/Internal/is_encoding_valid.php +++ b/src/Psl/Internal/is_encoding_valid.php @@ -4,12 +4,7 @@ namespace Psl\Internal; -use Psl; -use Psl\Type; -use Psl\Exception; - use function in_array; -use function mb_internal_encoding; use function mb_list_encodings; /** diff --git a/src/Psl/Internal/type.php b/src/Psl/Internal/type.php index 6fba796d..763c52d2 100644 --- a/src/Psl/Internal/type.php +++ b/src/Psl/Internal/type.php @@ -11,8 +11,6 @@ /** * @param mixed $value * - * @return string - * * @psalm-pure * * @codeCoverageIgnore diff --git a/src/Psl/Iter/Iterator.php b/src/Psl/Iter/Iterator.php index a17f160c..eda36013 100644 --- a/src/Psl/Iter/Iterator.php +++ b/src/Psl/Iter/Iterator.php @@ -16,7 +16,7 @@ * * @implements SeekableIterator */ -final class Iterator implements SeekableIterator, Countable +final class Iterator implements Countable, SeekableIterator { /** * @psalm-var Generator diff --git a/src/Psl/Iter/contains_key.php b/src/Psl/Iter/contains_key.php index 3abe76f6..2b0236d3 100644 --- a/src/Psl/Iter/contains_key.php +++ b/src/Psl/Iter/contains_key.php @@ -4,8 +4,6 @@ namespace Psl\Iter; -use Psl\Arr; - /** * Returns true if the given iterable contains the key. * diff --git a/src/Psl/Iter/count.php b/src/Psl/Iter/count.php index 5f257138..b644fc18 100644 --- a/src/Psl/Iter/count.php +++ b/src/Psl/Iter/count.php @@ -4,6 +4,8 @@ namespace Psl\Iter; +use function is_countable; + /** * Returns the number of elements an iterable contains. * @@ -26,7 +28,7 @@ */ function count(iterable $iterable): int { - if (\is_countable($iterable)) { + if (is_countable($iterable)) { return \count($iterable); } diff --git a/src/Psl/Iter/diff_by_key.php b/src/Psl/Iter/diff_by_key.php index 18d75fdf..1354f776 100644 --- a/src/Psl/Iter/diff_by_key.php +++ b/src/Psl/Iter/diff_by_key.php @@ -23,13 +23,13 @@ function diff_by_key(iterable $first, iterable $second, iterable ...$rest): Iter return; } - if (is_empty($second) && all($rest, fn (iterable $iter): bool => is_empty($iter))) { + if (is_empty($second) && all($rest, static fn (iterable $iter): bool => is_empty($iter))) { yield from $first; } // We don't use arrays here to ensure we allow the usage of non-arraykey indexes. /** @psalm-var Generator $second */ - $second = ((fn (iterable $iterable): Generator => yield from $iterable)($second)); + $second = ((static fn (iterable $iterable): Generator => yield from $iterable)($second)); /** @psalm-var Generator, mixed, mixed, void> $generator */ $generator = ((static function (Generator $second, iterable ...$rest): Generator { yield from $second; diff --git a/src/Psl/Iter/drop.php b/src/Psl/Iter/drop.php index 649ef590..51d8dff5 100644 --- a/src/Psl/Iter/drop.php +++ b/src/Psl/Iter/drop.php @@ -4,7 +4,6 @@ namespace Psl\Iter; -use Generator; use Psl; /** diff --git a/src/Psl/Iter/filter_with_key.php b/src/Psl/Iter/filter_with_key.php index bc6a8b1f..b791d41f 100644 --- a/src/Psl/Iter/filter_with_key.php +++ b/src/Psl/Iter/filter_with_key.php @@ -42,7 +42,7 @@ function filter_with_key(iterable $iterable, ?callable $predicate = null): Itera * * @return bool */ - fn ($k, $v) => Psl\Internal\boolean($v); + static fn ($k, $v) => Psl\Internal\boolean($v); foreach ($iterable as $k => $v) { if ($predicate($k, $v)) { diff --git a/src/Psl/Iter/first_key.php b/src/Psl/Iter/first_key.php index 98a0f773..4e23e5e9 100644 --- a/src/Psl/Iter/first_key.php +++ b/src/Psl/Iter/first_key.php @@ -4,8 +4,6 @@ namespace Psl\Iter; -use Psl\Arr; - /** * Gets the first key of an iterable. * diff --git a/src/Psl/Iter/product.php b/src/Psl/Iter/product.php index 2b39582c..19e7d17f 100644 --- a/src/Psl/Iter/product.php +++ b/src/Psl/Iter/product.php @@ -34,7 +34,7 @@ function product(iterable ...$iterables): Iterator /** @psalm-var list> $iterators */ $iterators = to_array(map( $iterables, - fn (iterable $iterable) => Iterator::create($iterable) + static fn (iterable $iterable) => Iterator::create($iterable) )); $numIterators = count($iterators); diff --git a/src/Psl/Iter/reduce_keys.php b/src/Psl/Iter/reduce_keys.php index aaf032a9..5ba6dc31 100644 --- a/src/Psl/Iter/reduce_keys.php +++ b/src/Psl/Iter/reduce_keys.php @@ -17,7 +17,7 @@ * Iter\range(1, 5), * static fn(int $accumulator, int $key): int => $accumulator + $key, * 0, - * ) + * ) * => 10 * * @psalm-template Tk diff --git a/src/Psl/Iter/reduce_with_keys.php b/src/Psl/Iter/reduce_with_keys.php index bf175ecb..886b2075 100644 --- a/src/Psl/Iter/reduce_with_keys.php +++ b/src/Psl/Iter/reduce_with_keys.php @@ -17,7 +17,7 @@ * Iter\range(1, 5), * static fn(int $accumulator, int $key, int $value): int => $accumulator + $value, * 0, - * ) + * ) * => 15 * * Iter\reduce_with_keys( diff --git a/src/Psl/Iter/repeat.php b/src/Psl/Iter/repeat.php index c557ed61..a87853f3 100644 --- a/src/Psl/Iter/repeat.php +++ b/src/Psl/Iter/repeat.php @@ -6,7 +6,6 @@ use Generator; use Psl; -use Psl\Internal; use Psl\Math; /** diff --git a/src/Psl/Iter/zip.php b/src/Psl/Iter/zip.php index 72550c71..822107e3 100644 --- a/src/Psl/Iter/zip.php +++ b/src/Psl/Iter/zip.php @@ -45,11 +45,11 @@ function zip(iterable ...$iterables): Iterator * * @psalm-return Iterator */ - fn ($iterable) => new Iterator((fn () => yield from $iterable)()), + static fn ($iterable) => new Iterator((static fn () => yield from $iterable)()), )); - apply($iterators, fn (Iterator $iterator) => $iterator->rewind()); - while (all($iterators, fn (Iterator $iterator) => $iterator->valid())) { + apply($iterators, static fn (Iterator $iterator) => $iterator->rewind()); + while (all($iterators, static fn (Iterator $iterator) => $iterator->valid())) { /** @psalm-var list $keys */ $keys = to_array(map( $iterators, @@ -58,7 +58,7 @@ function zip(iterable ...$iterables): Iterator * * @psalm-return Tk */ - fn (Iterator $iterator) => $iterator->key(), + static fn (Iterator $iterator) => $iterator->key(), )); /** @psalm-var list $values */ @@ -69,12 +69,12 @@ function zip(iterable ...$iterables): Iterator * * @psalm-return Tv */ - fn (Iterator $iterator) => $iterator->current(), + static fn (Iterator $iterator) => $iterator->current(), )); yield $keys => $values; - apply($iterators, fn (Iterator $iterator) => $iterator->next()); + apply($iterators, static fn (Iterator $iterator) => $iterator->next()); } }); } diff --git a/src/Psl/Math/max_by.php b/src/Psl/Math/max_by.php index a595d730..baadbe58 100644 --- a/src/Psl/Math/max_by.php +++ b/src/Psl/Math/max_by.php @@ -4,8 +4,6 @@ namespace Psl\Math; -use Psl; - /** * Returns the largest element of the given iterable, or null if the * iterable is empty. diff --git a/src/Psl/Password/verify.php b/src/Psl/Password/verify.php index 64023ea5..1546da28 100644 --- a/src/Psl/Password/verify.php +++ b/src/Psl/Password/verify.php @@ -4,8 +4,6 @@ namespace Psl\Password; -use Psl; - use function password_verify; /** diff --git a/src/Psl/PseudoRandom/float.php b/src/Psl/PseudoRandom/float.php index beb353d4..ddf63d7b 100644 --- a/src/Psl/PseudoRandom/float.php +++ b/src/Psl/PseudoRandom/float.php @@ -4,7 +4,6 @@ namespace Psl\PseudoRandom; -use Psl; use Psl\Math; /** diff --git a/src/Psl/Result/Failure.php b/src/Psl/Result/Failure.php index 693920b2..99a933ec 100644 --- a/src/Psl/Result/Failure.php +++ b/src/Psl/Result/Failure.php @@ -5,7 +5,6 @@ namespace Psl\Result; use Exception; -use Psl; /** * Represents the result of failed operation. diff --git a/src/Psl/Str/Byte/words.php b/src/Psl/Str/Byte/words.php index 17ea9946..a51f1ee7 100644 --- a/src/Psl/Str/Byte/words.php +++ b/src/Psl/Str/Byte/words.php @@ -4,6 +4,8 @@ namespace Psl\Str\Byte; +use function str_word_count; + /** * Return information about words used in a string. * @@ -18,10 +20,10 @@ function words(string $string, ?string $characters_list = null): array { if (null === $characters_list) { /** @var array $words */ - $words = \str_word_count($string, 2); + $words = str_word_count($string, 2); } else { /** @var array $words */ - $words = \str_word_count($string, 2, $characters_list); + $words = str_word_count($string, 2, $characters_list); } return $words; diff --git a/src/Psl/Str/convert_encoding.php b/src/Psl/Str/convert_encoding.php index 52b1d668..e17f0de1 100644 --- a/src/Psl/Str/convert_encoding.php +++ b/src/Psl/Str/convert_encoding.php @@ -23,8 +23,5 @@ function convert_encoding(string $string, string $from_encoding, string $to_enco Psl\invariant(Internal\is_encoding_valid($from_encoding), '$from_encoding is invalid.'); Psl\invariant(Internal\is_encoding_valid($to_encoding), '$to_encoding is invalid.'); - $result = mb_convert_encoding($string, $to_encoding, $from_encoding); - Psl\invariant(false !== $result, 'Unable to convert $string from $from_encoding to $to_encoding.'); - - return $result; + return mb_convert_encoding($string, $to_encoding, $from_encoding); } diff --git a/src/Psl/Type/Type.php b/src/Psl/Type/Type.php index 7ca92d0b..045a3c48 100644 --- a/src/Psl/Type/Type.php +++ b/src/Psl/Type/Type.php @@ -6,7 +6,6 @@ use Psl\Type\Exception\AssertException; use Psl\Type\Exception\CoercionException; -use Psl\Type\Exception\TypeTrace; use Psl\Type\Internal\TypeTraceTrait; /** diff --git a/tests/Psl/Arr/AtTest.php b/tests/Psl/Arr/AtTest.php index 1d8d36f1..43f20279 100644 --- a/tests/Psl/Arr/AtTest.php +++ b/tests/Psl/Arr/AtTest.php @@ -8,7 +8,7 @@ use Psl\Arr; use Psl\Exception; -class AtTest extends TestCase +final class AtTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/ConcatTest.php b/tests/Psl/Arr/ConcatTest.php index fc238f91..0fc011f2 100644 --- a/tests/Psl/Arr/ConcatTest.php +++ b/tests/Psl/Arr/ConcatTest.php @@ -6,9 +6,8 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -use Psl\Collection; -class ConcatTest extends TestCase +final class ConcatTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/ContainsKeyTest.php b/tests/Psl/Arr/ContainsKeyTest.php index fcce283d..e62e5877 100644 --- a/tests/Psl/Arr/ContainsKeyTest.php +++ b/tests/Psl/Arr/ContainsKeyTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class ContainsKeyTest extends TestCase +final class ContainsKeyTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/ContainsTest.php b/tests/Psl/Arr/ContainsTest.php index a1c1f37b..e7fffdd5 100644 --- a/tests/Psl/Arr/ContainsTest.php +++ b/tests/Psl/Arr/ContainsTest.php @@ -6,9 +6,8 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -use Psl\Collection; -class ContainsTest extends TestCase +final class ContainsTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/CountTest.php b/tests/Psl/Arr/CountTest.php index d07150af..a1e0cd87 100644 --- a/tests/Psl/Arr/CountTest.php +++ b/tests/Psl/Arr/CountTest.php @@ -6,11 +6,8 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -use Psl\Collection; -use Psl\Exception; -use Psl\Iter; -class CountTest extends TestCase +final class CountTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/CountValuesTest.php b/tests/Psl/Arr/CountValuesTest.php index a79b42e7..d718464d 100644 --- a/tests/Psl/Arr/CountValuesTest.php +++ b/tests/Psl/Arr/CountValuesTest.php @@ -8,9 +8,8 @@ use Psl\Arr; use Psl\Collection; use Psl\Exception; -use Psl\Iter; -class CountValuesTest extends TestCase +final class CountValuesTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/DropTest.php b/tests/Psl/Arr/DropTest.php index f94eb1f5..68d504f2 100644 --- a/tests/Psl/Arr/DropTest.php +++ b/tests/Psl/Arr/DropTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class DropTest extends TestCase +final class DropTest extends TestCase { /** * @dataProvider provideData @@ -16,7 +16,7 @@ public function testDrop(array $expected, array $array, int $n): void { $result = Arr\drop($array, $n); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideData(): iterable diff --git a/tests/Psl/Arr/DropWhileTest.php b/tests/Psl/Arr/DropWhileTest.php index 0e5da8f0..e7e9a806 100644 --- a/tests/Psl/Arr/DropWhileTest.php +++ b/tests/Psl/Arr/DropWhileTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class DropWhileTest extends TestCase +final class DropWhileTest extends TestCase { /** * @dataProvider provideData @@ -16,14 +16,14 @@ public function testDropWhile(array $expected, array $array, callable $callable) { $result = Arr\drop_while($array, $callable); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideData(): iterable { - yield [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], fn (int $_): bool => false]; - yield [[3 => 4, 4 => 5], [1, 2, 3, 4, 5], fn (int $i) => $i <= 3]; - yield [[2 => 3, 3 => 4, 4 => 5], [1, 2, 3, 4, 5], fn (int $i) => $i <= 2]; - yield [[], [1, 2, 3, 4, 5], fn (int $_) => true]; + yield [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], static fn (int $_): bool => false]; + yield [[3 => 4, 4 => 5], [1, 2, 3, 4, 5], static fn (int $i) => $i <= 3]; + yield [[2 => 3, 3 => 4, 4 => 5], [1, 2, 3, 4, 5], static fn (int $i) => $i <= 2]; + yield [[], [1, 2, 3, 4, 5], static fn (int $_) => true]; } } diff --git a/tests/Psl/Arr/EqualTest.php b/tests/Psl/Arr/EqualTest.php index 08515442..b5664ac0 100644 --- a/tests/Psl/Arr/EqualTest.php +++ b/tests/Psl/Arr/EqualTest.php @@ -8,7 +8,7 @@ use Psl\Arr; use Psl\Collection; -class EqualTest extends TestCase +final class EqualTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/FillTest.php b/tests/Psl/Arr/FillTest.php index 052b1215..f2e8526d 100644 --- a/tests/Psl/Arr/FillTest.php +++ b/tests/Psl/Arr/FillTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class FillTest extends TestCase +final class FillTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/FilterKeysTest.php b/tests/Psl/Arr/FilterKeysTest.php index c739490a..f247d7f9 100644 --- a/tests/Psl/Arr/FilterKeysTest.php +++ b/tests/Psl/Arr/FilterKeysTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class FilterKeysTest extends TestCase +final class FilterKeysTest extends TestCase { /** * @dataProvider provideData @@ -16,15 +16,15 @@ public function testFilterKeys(array $expected, array $array, ?callable $predica { $result = Arr\filter_keys($array, $predicate); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideData(): iterable { yield [[], []]; yield [[1 => 'b'], ['a', 'b']]; - yield [[], ['a', 'b'], fn () => false]; - yield [['a', 'b'], ['a', 'b'], fn (int $_): bool => true]; - yield [['a'], ['a', 'b'], fn (int $k): bool => 1 !== $k]; + yield [[], ['a', 'b'], static fn () => false]; + yield [['a', 'b'], ['a', 'b'], static fn (int $_): bool => true]; + yield [['a'], ['a', 'b'], static fn (int $k): bool => 1 !== $k]; } } diff --git a/tests/Psl/Arr/FilterNullsTest.php b/tests/Psl/Arr/FilterNullsTest.php index 0dfffb1d..2ce67a93 100644 --- a/tests/Psl/Arr/FilterNullsTest.php +++ b/tests/Psl/Arr/FilterNullsTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class FilterNullsTest extends TestCase +final class FilterNullsTest extends TestCase { public function testFilterNulls(): void { - self::assertCount(0, Arr\filter_nulls([])); - self::assertCount(0, Arr\filter_nulls([null, null])); - self::assertCount(1, Arr\filter_nulls([null, false])); - self::assertCount(1, Arr\filter_nulls([null, 'null'])); - self::assertCount(1, Arr\filter_nulls(['null'])); + static::assertCount(0, Arr\filter_nulls([])); + static::assertCount(0, Arr\filter_nulls([null, null])); + static::assertCount(1, Arr\filter_nulls([null, false])); + static::assertCount(1, Arr\filter_nulls([null, 'null'])); + static::assertCount(1, Arr\filter_nulls(['null'])); } } diff --git a/tests/Psl/Arr/FilterTest.php b/tests/Psl/Arr/FilterTest.php index 2336bb7e..4c40f0d4 100644 --- a/tests/Psl/Arr/FilterTest.php +++ b/tests/Psl/Arr/FilterTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class FilterTest extends TestCase +final class FilterTest extends TestCase { /** * @dataProvider provideData @@ -16,15 +16,15 @@ public function testFilter(array $expected, array $array, ?callable $predicate = { $result = Arr\filter($array, $predicate); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideData(): iterable { yield [[], []]; yield [['a', 'b'], ['a', 'b']]; - yield [[], ['a', 'b'], fn () => false]; - yield [['a', 'b'], ['a', 'b'], fn (string $_): bool => true]; - yield [['a'], ['a', 'b'], fn (string $v): bool => 'b' !== $v]; + yield [[], ['a', 'b'], static fn () => false]; + yield [['a', 'b'], ['a', 'b'], static fn (string $_): bool => true]; + yield [['a'], ['a', 'b'], static fn (string $v): bool => 'b' !== $v]; } } diff --git a/tests/Psl/Arr/FilterWithKeyTest.php b/tests/Psl/Arr/FilterWithKeyTest.php index 095c74d1..363e8414 100644 --- a/tests/Psl/Arr/FilterWithKeyTest.php +++ b/tests/Psl/Arr/FilterWithKeyTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class FilterWithKeyTest extends TestCase +final class FilterWithKeyTest extends TestCase { /** * @dataProvider provideData @@ -16,19 +16,19 @@ public function testFilterWithKey(array $expected, array $array, ?callable $pred { $result = Arr\filter_with_key($array, $predicate); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideData(): iterable { yield [[], []]; yield [['a', 'b'], ['a', 'b']]; - yield [[], ['a', 'b'], fn (int $_k, string $_v) => false]; - yield [['a', 'b'], ['a', 'b'], fn (int $_k, string $_v): bool => true]; - yield [['a'], ['a', 'b'], fn (int $k, string $v): bool => 'b' !== $v]; - yield [[], ['a', 'b'], fn (int $k, string $v): bool => 'b' !== $v && 0 !== $k]; - yield [['a'], ['a', 'b'], fn (int $k, string $v): bool => 'b' !== $v && 1 !== $k]; - yield [[], ['a', 'b'], fn (int $k, string $v): bool => 'a' !== $v && 1 !== $k]; - yield [[1 => 'b'], ['a', 'b'], fn (int $k, string $v): bool => 'a' !== $v && 0 !== $k]; + yield [[], ['a', 'b'], static fn (int $_k, string $_v) => false]; + yield [['a', 'b'], ['a', 'b'], static fn (int $_k, string $_v): bool => true]; + yield [['a'], ['a', 'b'], static fn (int $k, string $v): bool => 'b' !== $v]; + yield [[], ['a', 'b'], static fn (int $k, string $v): bool => 'b' !== $v && 0 !== $k]; + yield [['a'], ['a', 'b'], static fn (int $k, string $v): bool => 'b' !== $v && 1 !== $k]; + yield [[], ['a', 'b'], static fn (int $k, string $v): bool => 'a' !== $v && 1 !== $k]; + yield [[1 => 'b'], ['a', 'b'], static fn (int $k, string $v): bool => 'a' !== $v && 0 !== $k]; } } diff --git a/tests/Psl/Arr/FirstKeyTest.php b/tests/Psl/Arr/FirstKeyTest.php index 1159ef95..538e89a9 100644 --- a/tests/Psl/Arr/FirstKeyTest.php +++ b/tests/Psl/Arr/FirstKeyTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class FirstKeyTest extends TestCase +final class FirstKeyTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/FirstTest.php b/tests/Psl/Arr/FirstTest.php index b530b43c..48cec5d6 100644 --- a/tests/Psl/Arr/FirstTest.php +++ b/tests/Psl/Arr/FirstTest.php @@ -8,7 +8,7 @@ use Psl\Arr; use Psl\Iter; -class FirstTest extends TestCase +final class FirstTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/FirstxTest.php b/tests/Psl/Arr/FirstxTest.php index 658e1777..336b453c 100644 --- a/tests/Psl/Arr/FirstxTest.php +++ b/tests/Psl/Arr/FirstxTest.php @@ -9,7 +9,7 @@ use Psl\Exception; use Psl\Iter; -class FirstxTest extends TestCase +final class FirstxTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/FlattenTest.php b/tests/Psl/Arr/FlattenTest.php index 0acda689..f9a7effb 100644 --- a/tests/Psl/Arr/FlattenTest.php +++ b/tests/Psl/Arr/FlattenTest.php @@ -6,16 +6,15 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -use Psl\Collection; -class FlattenTest extends TestCase +final class FlattenTest extends TestCase { /** * @dataProvider provideData */ public function testFlatten(array $expected, array $arrays): void { - self::assertSame($expected, Arr\flatten($arrays)); + static::assertSame($expected, Arr\flatten($arrays)); } public function provideData(): array diff --git a/tests/Psl/Arr/FlipTest.php b/tests/Psl/Arr/FlipTest.php index 58c4d552..1f19b954 100644 --- a/tests/Psl/Arr/FlipTest.php +++ b/tests/Psl/Arr/FlipTest.php @@ -8,14 +8,14 @@ use Psl\Arr; use Psl\Exception; -class FlipTest extends TestCase +final class FlipTest extends TestCase { /** * @dataProvider provideData */ public function testFlip(array $expected, $actual): void { - self::assertSame($expected, Arr\flip($actual)); + static::assertSame($expected, Arr\flip($actual)); } public function provideData(): array diff --git a/tests/Psl/Arr/GroupByTest.php b/tests/Psl/Arr/GroupByTest.php index e909d424..9f09a7b6 100644 --- a/tests/Psl/Arr/GroupByTest.php +++ b/tests/Psl/Arr/GroupByTest.php @@ -8,17 +8,16 @@ use Psl\Arr; use Psl\Collection; use Psl\Exception; -use Psl\Iter; use Psl\Str; -class GroupByTest extends TestCase +final class GroupByTest extends TestCase { /** * @dataProvider provideData */ public function testGroupBy(array $expected, array $values, callable $callable): void { - self::assertSame($expected, Arr\group_by($values, $callable)); + static::assertSame($expected, Arr\group_by($values, $callable)); } public function provideData(): array @@ -27,19 +26,19 @@ public function provideData(): array [ [7 => [2], 8 => [3], 9 => [4], 10 => [5], 11 => [6], 12 => [7, 8, 9, 10]], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], - fn ($i) => $i < 2 ? null : (($i >= 7) ? 12 : ($i + 5)), + static fn ($i) => $i < 2 ? null : (($i >= 7) ? 12 : ($i + 5)), ], [ [7 => [2], 8 => [3], 9 => [4], 10 => [5], 11 => [6], 12 => [7], 13 => [8], 14 => [9], 15 => [10]], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], - fn ($i) => $i < 2 ? null : $i + 5, + static fn ($i) => $i < 2 ? null : $i + 5, ], [ ['username' => ['@azjezz', '@fabpot', '@blacksun'], 'name' => ['Saif Eddin', 'Fabien', 'Gabrielle']], ['@azjezz', 'Saif Eddin', '@fabpot', 'Fabien', '@blacksun', 'Gabrielle'], - fn ($name) => Str\starts_with($name, '@') ? 'username' : 'name', + static fn ($name) => Str\starts_with($name, '@') ? 'username' : 'name', ], ]; } @@ -53,7 +52,7 @@ public function testGroupByThrowsWhenKeyFunReturnsNonArrayKey(): void Arr\group_by( [0, 1, 2, 3, 4, 5], - fn ($x) => new Collection\Vector([$x, $x]) + static fn ($x) => new Collection\Vector([$x, $x]) ); } } diff --git a/tests/Psl/Arr/IdxTest.php b/tests/Psl/Arr/IdxTest.php index ad0b095a..27b41b13 100644 --- a/tests/Psl/Arr/IdxTest.php +++ b/tests/Psl/Arr/IdxTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class IdxTest extends TestCase +final class IdxTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/KeysTest.php b/tests/Psl/Arr/KeysTest.php index e1d45b8d..629c7222 100644 --- a/tests/Psl/Arr/KeysTest.php +++ b/tests/Psl/Arr/KeysTest.php @@ -7,7 +7,9 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class KeysTest extends TestCase +use function array_keys; + +final class KeysTest extends TestCase { public function testValues(): void { @@ -19,11 +21,11 @@ public function testValues(): void $keys = Arr\keys($array); - self::assertSameSize($keys, $array); - self::assertSame($keys, \array_keys($array)); + static::assertSameSize($keys, $array); + static::assertSame($keys, array_keys($array)); foreach ($array as $key => $value) { - self::assertTrue(Arr\contains($keys, $key)); + static::assertTrue(Arr\contains($keys, $key)); } } } diff --git a/tests/Psl/Arr/LastKeyTest.php b/tests/Psl/Arr/LastKeyTest.php index 5f0182ff..31ae1c58 100644 --- a/tests/Psl/Arr/LastKeyTest.php +++ b/tests/Psl/Arr/LastKeyTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class LastKeyTest extends TestCase +final class LastKeyTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/LastTest.php b/tests/Psl/Arr/LastTest.php index 041fd86c..aba1f0bc 100644 --- a/tests/Psl/Arr/LastTest.php +++ b/tests/Psl/Arr/LastTest.php @@ -8,7 +8,7 @@ use Psl\Arr; use Psl\Iter; -class LastTest extends TestCase +final class LastTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/LastxTest.php b/tests/Psl/Arr/LastxTest.php index 39fff79d..ab2fe675 100644 --- a/tests/Psl/Arr/LastxTest.php +++ b/tests/Psl/Arr/LastxTest.php @@ -9,7 +9,7 @@ use Psl\Exception; use Psl\Iter; -class LastxTest extends TestCase +final class LastxTest extends TestCase { /** * @dataProvider provideData diff --git a/tests/Psl/Arr/MapKeysTest.php b/tests/Psl/Arr/MapKeysTest.php index 280ae94c..ab98b8f3 100644 --- a/tests/Psl/Arr/MapKeysTest.php +++ b/tests/Psl/Arr/MapKeysTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class MapKeysTest extends TestCase +final class MapKeysTest extends TestCase { /** * @dataProvider provideData @@ -16,14 +16,14 @@ public function testMapKeys(array $expected, array $array, callable $function): { $result = Arr\map_keys($array, $function); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideData(): iterable { - yield [[1, 2, 3], [1, 2, 3], fn (int $k): int => $k]; - yield [[1, 2 => 2, 4 => 3], [1, 2, 3], fn (int $k): int => $k * 2]; - yield [['0' => 1, '1' => 2, '2' => 3], [1, 2, 3], fn (int $k): string => (string) $k]; - yield [[], [], fn (int $k): string => (string) $k]; + yield [[1, 2, 3], [1, 2, 3], static fn (int $k): int => $k]; + yield [[1, 2 => 2, 4 => 3], [1, 2, 3], static fn (int $k): int => $k * 2]; + yield [['0' => 1, '1' => 2, '2' => 3], [1, 2, 3], static fn (int $k): string => (string) $k]; + yield [[], [], static fn (int $k): string => (string) $k]; } } diff --git a/tests/Psl/Arr/MapTest.php b/tests/Psl/Arr/MapTest.php index 2497eddd..fc8d3c0c 100644 --- a/tests/Psl/Arr/MapTest.php +++ b/tests/Psl/Arr/MapTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class MapTest extends TestCase +final class MapTest extends TestCase { /** * @dataProvider provideData @@ -16,14 +16,14 @@ public function testMap(array $expected, array $array, callable $function): void { $result = Arr\map($array, $function); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideData(): iterable { - yield [[1, 2, 3], [1, 2, 3], fn (int $v): int => $v]; - yield [[2, 4, 6], [1, 2, 3], fn (int $v): int => $v * 2]; - yield [['1', '2', '3'], [1, 2, 3], fn (int $v): string => (string)$v]; - yield [[], [], fn (int $k): string => (string)$v]; + yield [[1, 2, 3], [1, 2, 3], static fn (int $v): int => $v]; + yield [[2, 4, 6], [1, 2, 3], static fn (int $v): int => $v * 2]; + yield [['1', '2', '3'], [1, 2, 3], static fn (int $v): string => (string)$v]; + yield [[], [], static fn (int $k): string => (string)$v]; } } diff --git a/tests/Psl/Arr/MapWithKeyTest.php b/tests/Psl/Arr/MapWithKeyTest.php index 5be7b56a..323628ce 100644 --- a/tests/Psl/Arr/MapWithKeyTest.php +++ b/tests/Psl/Arr/MapWithKeyTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class MapWithKeyTest extends TestCase +final class MapWithKeyTest extends TestCase { /** * @dataProvider provideData @@ -16,14 +16,14 @@ public function testMapWithKey(array $expected, array $array, callable $function { $result = Arr\map_with_key($array, $function); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideData(): iterable { - yield [[1, 3, 5], [1, 2, 3], fn (int $k, int $v): int => $k + $v]; - yield [[0, 4, 16], [1, 2, 3], fn (int $k, int $v): int => $k * (2 ** $v)]; - yield [['1', '3', '5'], [1, 2, 3], fn (int $k, int $v): string => (string) ($k + $v)]; - yield [[], [], fn (int $k, int $v): string => (string) ($k + $v)]; + yield [[1, 3, 5], [1, 2, 3], static fn (int $k, int $v): int => $k + $v]; + yield [[0, 4, 16], [1, 2, 3], static fn (int $k, int $v): int => $k * (2 ** $v)]; + yield [['1', '3', '5'], [1, 2, 3], static fn (int $k, int $v): string => (string) ($k + $v)]; + yield [[], [], static fn (int $k, int $v): string => (string) ($k + $v)]; } } diff --git a/tests/Psl/Arr/MergeTest.php b/tests/Psl/Arr/MergeTest.php index 19d324ed..ade7b29e 100644 --- a/tests/Psl/Arr/MergeTest.php +++ b/tests/Psl/Arr/MergeTest.php @@ -6,16 +6,15 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -use Psl\Collection; -class MergeTest extends TestCase +final class MergeTest extends TestCase { /** * @dataProvider provideData */ public function testMerge(array $expected, array $array, array ...$arrays): void { - self::assertSame($expected, Arr\merge($array, ...$arrays)); + static::assertSame($expected, Arr\merge($array, ...$arrays)); } public function provideData(): array diff --git a/tests/Psl/Arr/PartitionTest.php b/tests/Psl/Arr/PartitionTest.php index 5b4b8c7c..67b7b535 100644 --- a/tests/Psl/Arr/PartitionTest.php +++ b/tests/Psl/Arr/PartitionTest.php @@ -8,14 +8,14 @@ use Psl\Arr; use Psl\Str; -class PartitionTest extends TestCase +final class PartitionTest extends TestCase { /** * @dataProvider provideData */ public function testPartition(array $expected, array $array, callable $predicate): void { - self::assertSame($expected, Arr\partition($array, $predicate)); + static::assertSame($expected, Arr\partition($array, $predicate)); } public function provideData(): array @@ -24,31 +24,31 @@ public function provideData(): array [ [['bar', 'baz'], ['foo', 'qux']], ['foo', 'bar', 'baz', 'qux'], - fn (string $str) => Str\starts_with($str, 'b'), + static fn (string $str) => Str\starts_with($str, 'b'), ], [ [['bar', 'baz'], ['foo', 'qux']], ['foo', 'bar', 'baz', 'qux'], - fn (string $str) => Str\starts_with($str, 'b'), + static fn (string $str) => Str\starts_with($str, 'b'), ], [ [[], []], [], - fn ($_) => false, + static fn ($_) => false, ], [ [[], ['foo', 'bar', 'baz', 'qux']], ['foo', 'bar', 'baz', 'qux'], - fn (string $str) => false, + static fn (string $str) => false, ], [ [['foo', 'bar', 'baz', 'qux'], []], ['foo', 'bar', 'baz', 'qux'], - fn (string $str) => true, + static fn (string $str) => true, ], ]; } diff --git a/tests/Psl/Arr/RandomTest.php b/tests/Psl/Arr/RandomTest.php index 5bf6226c..94961fb5 100644 --- a/tests/Psl/Arr/RandomTest.php +++ b/tests/Psl/Arr/RandomTest.php @@ -8,7 +8,7 @@ use Psl\Arr; use Psl\Exception; -class RandomTest extends TestCase +final class RandomTest extends TestCase { public function testRandom(): void { diff --git a/tests/Psl/Arr/SelectKeysTest.php b/tests/Psl/Arr/SelectKeysTest.php index 6ad1d962..ce55593c 100644 --- a/tests/Psl/Arr/SelectKeysTest.php +++ b/tests/Psl/Arr/SelectKeysTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class SelectKeysTest extends TestCase +final class SelectKeysTest extends TestCase { /** * @dataProvider provideData */ public function testSelectKeys(array $result, array $array, array $keys): void { - self::assertSame($result, Arr\select_keys($array, $keys)); + static::assertSame($result, Arr\select_keys($array, $keys)); } public function provideData(): array diff --git a/tests/Psl/Arr/ShuffleTest.php b/tests/Psl/Arr/ShuffleTest.php index d56aad32..9b620c0b 100644 --- a/tests/Psl/Arr/ShuffleTest.php +++ b/tests/Psl/Arr/ShuffleTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class ShuffleTest extends TestCase +final class ShuffleTest extends TestCase { public function testShuffle(): void { @@ -23,7 +23,7 @@ public function testShuffle(): void static::assertNotSame($shuffled, $array); foreach ($shuffled as $value) { - self::assertTrue(Arr\contains($array, $value)); + static::assertTrue(Arr\contains($array, $value)); } } } diff --git a/tests/Psl/Arr/SliceTest.php b/tests/Psl/Arr/SliceTest.php index ea3b186a..e23713f5 100644 --- a/tests/Psl/Arr/SliceTest.php +++ b/tests/Psl/Arr/SliceTest.php @@ -8,27 +8,27 @@ use Psl; use Psl\Arr; -class SliceTest extends TestCase +final class SliceTest extends TestCase { public function testSlice(): void { $result = Arr\slice([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5], 5); - self::assertSame([5 => 0, 6 => 1, 7 => 2, 8 => 3, 9 => 4, 10 => 5], $result); + static::assertSame([5 => 0, 6 => 1, 7 => 2, 8 => 3, 9 => 4, 10 => 5], $result); } public function testSliceWithLength(): void { $result = Arr\slice([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5], 5, 3); - self::assertSame([5 => 0, 6 => 1, 7 => 2], $result); + static::assertSame([5 => 0, 6 => 1, 7 => 2], $result); } public function testSliceWithZeroLength(): void { $result = Arr\slice([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5], 5, 0); - self::assertSame([], $result); + static::assertSame([], $result); } public function testSliceThrowsIfStartIsNegative(): void diff --git a/tests/Psl/Arr/SortByKeyTest.php b/tests/Psl/Arr/SortByKeyTest.php index a03cb38c..70e59a92 100644 --- a/tests/Psl/Arr/SortByKeyTest.php +++ b/tests/Psl/Arr/SortByKeyTest.php @@ -8,14 +8,14 @@ use Psl\Arr; use Psl\Str; -class SortByKeyTest extends TestCase +final class SortByKeyTest extends TestCase { /** * @dataProvider provideData */ public function testSortByKey(array $expected, array $array, ?callable $comparator = null): void { - self::assertSame($expected, Arr\sort_by_key($array, $comparator)); + static::assertSame($expected, Arr\sort_by_key($array, $comparator)); } public function provideData(): array @@ -30,7 +30,7 @@ public function provideData(): array [ ['d' => 'lemon', 'c' => 'apple', 'b' => 'banana', 'a' => 'orange'], ['d' => 'lemon', 'a' => 'orange', 'b' => 'banana', 'c' => 'apple'], - fn (string $a, string $b) => Str\ord($a) > Str\ord($b) ? -1 : 1, + static fn (string $a, string $b) => Str\ord($a) > Str\ord($b) ? -1 : 1, ], ]; } diff --git a/tests/Psl/Arr/SortByTest.php b/tests/Psl/Arr/SortByTest.php index b28b89bf..0f578988 100644 --- a/tests/Psl/Arr/SortByTest.php +++ b/tests/Psl/Arr/SortByTest.php @@ -6,17 +6,16 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -use Psl\Collection; use Psl\Str; -class SortByTest extends TestCase +final class SortByTest extends TestCase { /** * @dataProvider provideData */ public function testSortBy(array $expected, array $array, callable $scalar_fun, ?callable $comp = null): void { - self::assertSame($expected, Arr\sort_by($array, $scalar_fun, $comp)); + static::assertSame($expected, Arr\sort_by($array, $scalar_fun, $comp)); } public function provideData(): array @@ -34,7 +33,7 @@ public function provideData(): array * * @psalm-pure */ - fn ($arr) => Arr\count($arr); + static fn ($arr) => Arr\count($arr); return [ [ @@ -53,7 +52,7 @@ public function provideData(): array * * @psalm-pure */ - fn ($v) => $v, + static fn ($v) => $v, ], [ @@ -66,7 +65,7 @@ public function provideData(): array * * @psalm-pure */ - fn ($v) => $v, + static fn ($v) => $v, ], [ @@ -79,7 +78,7 @@ public function provideData(): array * * @psalm-pure */ - fn ($v) => $v, + static fn ($v) => $v, /** * @param string $a * @param string $b @@ -88,7 +87,7 @@ public function provideData(): array * * @psalm-pure */ - fn (string $a, string $b) => Str\ord($a) > Str\ord($b) ? -1 : 1, + static fn (string $a, string $b) => Str\ord($a) > Str\ord($b) ? -1 : 1, ], [ @@ -101,7 +100,7 @@ public function provideData(): array * * @psalm-pure */ - fn ($v) => $v, + static fn ($v) => $v, ], [ @@ -114,7 +113,7 @@ public function provideData(): array * * @psalm-pure */ - fn ($v) => Str\Byte\reverse($v), + static fn ($v) => Str\Byte\reverse($v), ], ]; } diff --git a/tests/Psl/Arr/SortTest.php b/tests/Psl/Arr/SortTest.php index f3b94184..d6ff6e6d 100644 --- a/tests/Psl/Arr/SortTest.php +++ b/tests/Psl/Arr/SortTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class SortTest extends TestCase +final class SortTest extends TestCase { /** * @dataProvider provideData @@ -36,7 +36,7 @@ public function provideData(): array * * @psalm-pure */ - fn (int $a, int $b) => $a <=> $b ? -1 : 1, + static fn (int $a, int $b) => $a <=> $b ? -1 : 1, ], [ diff --git a/tests/Psl/Arr/SortWithKeysByTest.php b/tests/Psl/Arr/SortWithKeysByTest.php index 2e296bcb..c9956dc2 100644 --- a/tests/Psl/Arr/SortWithKeysByTest.php +++ b/tests/Psl/Arr/SortWithKeysByTest.php @@ -6,17 +6,16 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -use Psl\Collection; use Psl\Str; -class SortWithKeysByTest extends TestCase +final class SortWithKeysByTest extends TestCase { /** * @dataProvider provideData */ public function testSortBy(array $expected, array $array, callable $scalar_fun, ?callable $comp = null): void { - self::assertSame($expected, Arr\sort_with_keys_by($array, $scalar_fun, $comp)); + static::assertSame($expected, Arr\sort_with_keys_by($array, $scalar_fun, $comp)); } public function provideData(): array @@ -26,7 +25,7 @@ public function provideData(): array $c = ['a' => 'foo', 'b' => 'bar', 'c' => 'baz', 'd' => 'qux', 'e' => 'lax']; $expected = [2 => $a, 0 => $b, 1 => $c]; $array = [$b, $c, $a]; - $scalar_fun = fn ($arr) => Arr\count($arr); + $scalar_fun = static fn ($arr) => Arr\count($arr); return [ [ @@ -45,7 +44,7 @@ public function provideData(): array * * @psalm-pure */ - fn ($v) => $v, + static fn ($v) => $v, ], [ @@ -58,7 +57,7 @@ public function provideData(): array * * @psalm-pure */ - fn ($v) => $v, + static fn ($v) => $v, ], [ @@ -71,7 +70,7 @@ public function provideData(): array * * @psalm-pure */ - fn ($v) => $v, + static fn ($v) => $v, /** * @param string $a * @param string $b @@ -80,7 +79,7 @@ public function provideData(): array * * @psalm-pure */ - fn (string $a, string $b) => Str\ord($a) > Str\ord($b) ? -1 : 1, + static fn (string $a, string $b) => Str\ord($a) > Str\ord($b) ? -1 : 1, ], [ @@ -93,7 +92,7 @@ public function provideData(): array * * @psalm-pure */ - fn ($v) => $v, + static fn ($v) => $v, ], [ @@ -106,7 +105,7 @@ public function provideData(): array * * @psalm-pure */ - fn ($v) => Str\Byte\reverse($v), + static fn ($v) => Str\Byte\reverse($v), ], ]; } diff --git a/tests/Psl/Arr/SortWithKeysTest.php b/tests/Psl/Arr/SortWithKeysTest.php index 8290d71b..52b09f11 100644 --- a/tests/Psl/Arr/SortWithKeysTest.php +++ b/tests/Psl/Arr/SortWithKeysTest.php @@ -6,10 +6,8 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -use Psl\Collection; -use Psl\Iter; -class SortWithKeysTest extends TestCase +final class SortWithKeysTest extends TestCase { /** * @dataProvider provideData @@ -30,7 +28,7 @@ public function provideData(): array [ [8, 9, 10], [8, 9, 10], - fn (int $a, int $b) => $a <=> $b ? -1 : 1, + static fn (int $a, int $b) => $a <=> $b ? -1 : 1, ], [ diff --git a/tests/Psl/Arr/TakeTest.php b/tests/Psl/Arr/TakeTest.php index 4855bc27..bb9789ec 100644 --- a/tests/Psl/Arr/TakeTest.php +++ b/tests/Psl/Arr/TakeTest.php @@ -8,13 +8,13 @@ use Psl; use Psl\Arr; -class TakeTest extends TestCase +final class TakeTest extends TestCase { public function testTake(): void { $result = Arr\take([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5], 3); - self::assertSame([-5, -4, -3], $result); + static::assertSame([-5, -4, -3], $result); } public function testTakeThrowsIfLengthIsNegative(): void diff --git a/tests/Psl/Arr/TakeWhileTest.php b/tests/Psl/Arr/TakeWhileTest.php index e2a98232..962f800d 100644 --- a/tests/Psl/Arr/TakeWhileTest.php +++ b/tests/Psl/Arr/TakeWhileTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class TakeWhileTest extends TestCase +final class TakeWhileTest extends TestCase { /** * @dataProvider provideData @@ -16,14 +16,14 @@ public function testTakeWhile(array $expected, array $array, callable $callable) { $result = Arr\take_while($array, $callable); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideData(): iterable { - yield [[], [1, 2, 3, 4, 5], fn (int $_): bool => false]; - yield [[1, 2, 3], [1, 2, 3, 4, 5], fn (int $i) => $i <= 3]; - yield [[1, 2], [1, 2, 3, 4, 5], fn (int $i) => $i <= 2]; - yield [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], fn (int $_) => true]; + yield [[], [1, 2, 3, 4, 5], static fn (int $_): bool => false]; + yield [[1, 2, 3], [1, 2, 3, 4, 5], static fn (int $i) => $i <= 3]; + yield [[1, 2], [1, 2, 3, 4, 5], static fn (int $i) => $i <= 2]; + yield [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], static fn (int $_) => true]; } } diff --git a/tests/Psl/Arr/UniqueByTest.php b/tests/Psl/Arr/UniqueByTest.php index 25dcd503..d66b48ac 100644 --- a/tests/Psl/Arr/UniqueByTest.php +++ b/tests/Psl/Arr/UniqueByTest.php @@ -8,7 +8,7 @@ use Psl\Arr; use Psl\Str; -class UniqueByTest extends TestCase +final class UniqueByTest extends TestCase { /** * @dataProvider provideData @@ -24,13 +24,13 @@ public function provideData(): array [ [0 => 'a', 4 => 'saif'], ['a', 'b', 'c', 'd', 'saif', 'jack'], - fn (string $value): int => Str\length($value), + static fn (string $value): int => Str\length($value), ], [ [0 => 'foo', 2 => 'bar', 4 => '@baz'], ['foo', '@foo', 'bar', '@bar', '@baz'], - fn (string $value): string => Str\replace($value, '@', ''), + static fn (string $value): string => Str\replace($value, '@', ''), ], ]; } diff --git a/tests/Psl/Arr/UniqueTest.php b/tests/Psl/Arr/UniqueTest.php index 1d8b6310..701a1e0d 100644 --- a/tests/Psl/Arr/UniqueTest.php +++ b/tests/Psl/Arr/UniqueTest.php @@ -8,7 +8,7 @@ use Psl\Arr; use Psl\Collection; -class UniqueTest extends TestCase +final class UniqueTest extends TestCase { public function testUnique(): void { diff --git a/tests/Psl/Arr/ValuesTest.php b/tests/Psl/Arr/ValuesTest.php index cb88d696..e0d69e8a 100644 --- a/tests/Psl/Arr/ValuesTest.php +++ b/tests/Psl/Arr/ValuesTest.php @@ -7,7 +7,9 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -class ValuesTest extends TestCase +use function array_values; + +final class ValuesTest extends TestCase { public function testValues(): void { @@ -19,11 +21,11 @@ public function testValues(): void $values = Arr\values($array); - self::assertSameSize($values, $array); - self::assertSame($values, \array_values($array)); + static::assertSameSize($values, $array); + static::assertSame($values, array_values($array)); foreach ($array as $value) { - self::assertTrue(Arr\contains($values, $value)); + static::assertTrue(Arr\contains($values, $value)); } } } diff --git a/tests/Psl/Collection/AbstractMapTest.php b/tests/Psl/Collection/AbstractMapTest.php index 31909a8a..f6aecc29 100644 --- a/tests/Psl/Collection/AbstractMapTest.php +++ b/tests/Psl/Collection/AbstractMapTest.php @@ -32,16 +32,16 @@ abstract class AbstractMapTest extends TestCase public function testIsEmpty(): void { - self::assertTrue($this->create([])->isEmpty()); - self::assertFalse($this->create(['foo' => 'bar'])->isEmpty()); - self::assertEmpty($this->create(['foo' => null])->isEmpty()); + static::assertTrue($this->create([])->isEmpty()); + static::assertFalse($this->create(['foo' => 'bar'])->isEmpty()); + static::assertEmpty($this->create(['foo' => null])->isEmpty()); } public function testCount(): void { - self::assertCount(0, $this->create([])); - self::assertCount(1, $this->create(['foo' => 'bar'])); - self::assertSame(5, $this->create([ + static::assertCount(0, $this->create([])); + static::assertCount(1, $this->create(['foo' => 'bar'])); + static::assertSame(5, $this->create([ 1 => 'foo', 2 => 'bar', 4 => 'baz', @@ -60,19 +60,19 @@ public function testValues(): void $values = $map->values(); - self::assertInstanceOf($this->vectorClass, $values); + static::assertInstanceOf($this->vectorClass, $values); - self::assertCount(3, $values); + static::assertCount(3, $values); - self::assertSame(1, $values->at(0)); - self::assertSame(2, $values->at(1)); - self::assertSame(3, $values->at(2)); + static::assertSame(1, $values->at(0)); + static::assertSame(2, $values->at(1)); + static::assertSame(3, $values->at(2)); $map = $this->create([]); $values = $map->values(); - self::assertInstanceOf($this->vectorClass, $values); + static::assertInstanceOf($this->vectorClass, $values); - self::assertCount(0, $values); + static::assertCount(0, $values); } public function testJsonSerialize(): void @@ -101,17 +101,17 @@ public function testKeys(): void ]); $keys = $map->keys(); - self::assertInstanceOf($this->vectorClass, $keys); - self::assertCount(3, $keys); - self::assertSame('foo', $keys->at(0)); - self::assertSame('bar', $keys->at(1)); - self::assertSame('baz', $keys->at(2)); + static::assertInstanceOf($this->vectorClass, $keys); + static::assertCount(3, $keys); + static::assertSame('foo', $keys->at(0)); + static::assertSame('bar', $keys->at(1)); + static::assertSame('baz', $keys->at(2)); $map = $this->create([]); $keys = $map->keys(); - self::assertInstanceOf($this->vectorClass, $keys); - self::assertCount(0, $keys); + static::assertInstanceOf($this->vectorClass, $keys); + static::assertCount(0, $keys); } public function testFilter(): void @@ -123,15 +123,15 @@ public function testFilter(): void 3 => 'qux', ]); - $filtered = $map->filter(fn (string $item) => Str\contains($item, 'b')); + $filtered = $map->filter(static fn (string $item) => Str\contains($item, 'b')); - self::assertInstanceOf($this->mapClass, $filtered); - self::assertNotSame($map, $filtered); - self::assertContains('bar', $filtered); - self::assertContains('baz', $filtered); - self::assertNotContains('foo', $filtered); - self::assertNotContains('qux', $filtered); - self::assertCount(2, $filtered); + static::assertInstanceOf($this->mapClass, $filtered); + static::assertNotSame($map, $filtered); + static::assertContains('bar', $filtered); + static::assertContains('baz', $filtered); + static::assertNotContains('foo', $filtered); + static::assertNotContains('qux', $filtered); + static::assertCount(2, $filtered); $map = $this->create([ 0 => 'foo', @@ -140,14 +140,14 @@ public function testFilter(): void 3 => 'qux', ]); - $filtered = $map->filter(fn (string $item) => Str\contains($item, 'hello')); + $filtered = $map->filter(static fn (string $item) => Str\contains($item, 'hello')); - self::assertInstanceOf($this->mapClass, $filtered); - self::assertNotContains('bar', $filtered); - self::assertNotContains('baz', $filtered); - self::assertNotContains('foo', $filtered); - self::assertNotContains('qux', $filtered); - self::assertCount(0, $filtered); + static::assertInstanceOf($this->mapClass, $filtered); + static::assertNotContains('bar', $filtered); + static::assertNotContains('baz', $filtered); + static::assertNotContains('foo', $filtered); + static::assertNotContains('qux', $filtered); + static::assertCount(0, $filtered); } public function testFilterWithKey(): void @@ -159,15 +159,15 @@ public function testFilterWithKey(): void 3 => 'qux', ]); - $filtered = $map->filterWithKey(fn (int $k, string $v) => 'foo' === $v || 3 === $k); + $filtered = $map->filterWithKey(static fn (int $k, string $v) => 'foo' === $v || 3 === $k); - self::assertInstanceOf($this->mapClass, $filtered); - self::assertNotSame($map, $filtered); - self::assertContains('foo', $filtered); - self::assertContains('qux', $filtered); - self::assertNotContains('bar', $filtered); - self::assertNotContains('baz', $filtered); - self::assertCount(2, $filtered); + static::assertInstanceOf($this->mapClass, $filtered); + static::assertNotSame($map, $filtered); + static::assertContains('foo', $filtered); + static::assertContains('qux', $filtered); + static::assertNotContains('bar', $filtered); + static::assertNotContains('baz', $filtered); + static::assertCount(2, $filtered); $map = $this->create([ 0 => 'foo', @@ -176,14 +176,14 @@ public function testFilterWithKey(): void 3 => 'qux', ]); - $filtered = $map->filterWithKey(fn (int $k, string $v) => 4 === $k); + $filtered = $map->filterWithKey(static fn (int $k, string $v) => 4 === $k); - self::assertInstanceOf($this->mapClass, $filtered); - self::assertNotContains('bar', $filtered); - self::assertNotContains('baz', $filtered); - self::assertNotContains('foo', $filtered); - self::assertNotContains('qux', $filtered); - self::assertCount(0, $filtered); + static::assertInstanceOf($this->mapClass, $filtered); + static::assertNotContains('bar', $filtered); + static::assertNotContains('baz', $filtered); + static::assertNotContains('foo', $filtered); + static::assertNotContains('qux', $filtered); + static::assertCount(0, $filtered); } public function testMap(): void @@ -195,17 +195,17 @@ public function testMap(): void 3 => 'qux', ]); - $mapped = $map->map(fn (string $item) => Str\uppercase($item)); + $mapped = $map->map(static fn (string $item) => Str\uppercase($item)); - self::assertInstanceOf($this->mapClass, $mapped); - self::assertSame([ + static::assertInstanceOf($this->mapClass, $mapped); + static::assertSame([ 0 => 'FOO', 1 => 'BAR', 2 => 'BAZ', 3 => 'QUX', ], $mapped->toArray()); - self::assertNotSame($map, $mapped); - self::assertCount(4, $mapped); + static::assertNotSame($map, $mapped); + static::assertCount(4, $mapped); $map = $this->create([ 0 => 'foo', @@ -214,12 +214,12 @@ public function testMap(): void 3 => 'qux', ]); - $mapped = $map->map(fn (string $item) => $item); + $mapped = $map->map(static fn (string $item) => $item); - self::assertInstanceOf($this->mapClass, $mapped); - self::assertNotSame($map, $mapped); - self::assertSame($map->toArray(), $mapped->toArray()); - self::assertCount(4, $mapped); + static::assertInstanceOf($this->mapClass, $mapped); + static::assertNotSame($map, $mapped); + static::assertSame($map->toArray(), $mapped->toArray()); + static::assertCount(4, $mapped); } public function testMapWithKey(): void @@ -231,17 +231,17 @@ public function testMapWithKey(): void 3 => 'qux', ]); - $mapped = $map->mapWithKey(fn (int $k, string $v) => Str\format('%s ( %d )', $v, $k)); + $mapped = $map->mapWithKey(static fn (int $k, string $v) => Str\format('%s ( %d )', $v, $k)); - self::assertInstanceOf($this->mapClass, $mapped); - self::assertSame([ + static::assertInstanceOf($this->mapClass, $mapped); + static::assertSame([ 0 => 'foo ( 0 )', 1 => 'bar ( 1 )', 2 => 'baz ( 2 )', 3 => 'qux ( 3 )', ], $mapped->toArray()); - self::assertNotSame($map, $mapped); - self::assertCount(4, $mapped); + static::assertNotSame($map, $mapped); + static::assertCount(4, $mapped); $map = $this->create([ 0 => 'foo', @@ -250,249 +250,249 @@ public function testMapWithKey(): void 3 => 'qux', ]); - $mapped = $map->mapWithKey(fn (int $k, string $v) => $k); + $mapped = $map->mapWithKey(static fn (int $k, string $v) => $k); - self::assertInstanceOf($this->mapClass, $mapped); - self::assertNotSame($map, $mapped); - self::assertSame($map->keys()->toArray(), $mapped->toArray()); - self::assertCount(4, $mapped); + static::assertInstanceOf($this->mapClass, $mapped); + static::assertNotSame($map, $mapped); + static::assertSame($map->keys()->toArray(), $mapped->toArray()); + static::assertCount(4, $mapped); - $mapped = $map->mapWithKey(fn (int $k, string $v) => $v); + $mapped = $map->mapWithKey(static fn (int $k, string $v) => $v); - self::assertInstanceOf($this->mapClass, $mapped); - self::assertNotSame($map, $mapped); - self::assertSame($map->toArray(), $mapped->toArray()); - self::assertCount(4, $mapped); + static::assertInstanceOf($this->mapClass, $mapped); + static::assertNotSame($map, $mapped); + static::assertSame($map->toArray(), $mapped->toArray()); + static::assertCount(4, $mapped); } public function testFirst(): void { $map = $this->create([]); - self::assertNull($map->first()); + static::assertNull($map->first()); $map = $this->create(['foo' => null]); - self::assertNull($map->first()); + static::assertNull($map->first()); $map = $this->create([0 => 'foo']); - self::assertSame('foo', $map->first()); + static::assertSame('foo', $map->first()); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); - self::assertSame('bar', $map->first()); + static::assertSame('bar', $map->first()); } public function testFirstKey(): void { $map = $this->create([]); - self::assertNull($map->firstKey()); + static::assertNull($map->firstKey()); $map = $this->create(['foo' => null]); - self::assertSame('foo', $map->firstKey()); + static::assertSame('foo', $map->firstKey()); $map = $this->create([0 => 'foo']); - self::assertSame(0, $map->firstKey()); + static::assertSame(0, $map->firstKey()); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); - self::assertSame('foo', $map->firstKey()); + static::assertSame('foo', $map->firstKey()); } public function testLast(): void { $map = $this->create([]); - self::assertNull($map->last()); + static::assertNull($map->last()); $map = $this->create(['foo' => null]); - self::assertNull($map->last()); + static::assertNull($map->last()); $map = $this->create([0 => 'foo']); - self::assertSame('foo', $map->last()); + static::assertSame('foo', $map->last()); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); - self::assertSame('qux', $map->last()); + static::assertSame('qux', $map->last()); } public function testLastKey(): void { $map = $this->create([]); - self::assertNull($map->lastKey()); + static::assertNull($map->lastKey()); $map = $this->create(['foo' => null]); - self::assertSame('foo', $map->lastKey()); + static::assertSame('foo', $map->lastKey()); $map = $this->create([0 => 'foo']); - self::assertSame(0, $map->lastKey()); + static::assertSame(0, $map->lastKey()); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); - self::assertSame('baz', $map->lastKey()); + static::assertSame('baz', $map->lastKey()); } public function testLinearSearch(): void { $map = $this->create([]); - self::assertNull($map->linearSearch('foo')); + static::assertNull($map->linearSearch('foo')); $map = $this->create([ 'foo' => 'bar', 'baz' => 'qux', ]); - self::assertSame('foo', $map->linearSearch('bar')); - self::assertSame('baz', $map->linearSearch('qux')); - self::assertNull($map->linearSearch('foo')); - self::assertNull($map->linearSearch('baz')); + static::assertSame('foo', $map->linearSearch('bar')); + static::assertSame('baz', $map->linearSearch('qux')); + static::assertNull($map->linearSearch('foo')); + static::assertNull($map->linearSearch('baz')); } public function testZip(): void { $map = $this->create([]); $zipped = $map->zip([]); - self::assertInstanceOf($this->mapClass, $zipped); - self::assertCount(0, $zipped); + static::assertInstanceOf($this->mapClass, $zipped); + static::assertCount(0, $zipped); $map = $this->create([]); $zipped = $map->zip([1, 2]); - self::assertInstanceOf($this->mapClass, $zipped); - self::assertCount(0, $zipped); + static::assertInstanceOf($this->mapClass, $zipped); + static::assertCount(0, $zipped); $map = $this->create([1 => 'foo', 2 => 'bar']); $zipped = $map->zip([]); - self::assertInstanceOf($this->mapClass, $zipped); - self::assertCount(0, $zipped); + static::assertInstanceOf($this->mapClass, $zipped); + static::assertCount(0, $zipped); $map = $this->create([1 => 'foo', 2 => 'bar']); $zipped = $map->zip(['baz', 'qux']); - self::assertInstanceOf($this->mapClass, $zipped); - self::assertCount(2, $zipped); - self::assertSame(['foo', 'baz'], $zipped->at(1)); - self::assertSame(['bar', 'qux'], $zipped->at(2)); + static::assertInstanceOf($this->mapClass, $zipped); + static::assertCount(2, $zipped); + static::assertSame(['foo', 'baz'], $zipped->at(1)); + static::assertSame(['bar', 'qux'], $zipped->at(2)); $map = $this->create([1 => 'foo', 2 => 'bar', 3 => 'baz', 4 => 'qux']); $zipped = $map->zip(['hello', 'world']); - self::assertInstanceOf($this->mapClass, $zipped); - self::assertCount(2, $zipped); - self::assertSame(['foo', 'hello'], $zipped->at(1)); - self::assertSame(['bar', 'world'], $zipped->at(2)); + static::assertInstanceOf($this->mapClass, $zipped); + static::assertCount(2, $zipped); + static::assertSame(['foo', 'hello'], $zipped->at(1)); + static::assertSame(['bar', 'world'], $zipped->at(2)); $map = $this->create([1 => 'hello', 2 => 'world']); $zipped = $map->zip(['foo', 'bar', 'baz', 'qux']); - self::assertInstanceOf($this->mapClass, $zipped); - self::assertCount(2, $zipped); - self::assertSame(['hello', 'foo'], $zipped->at(1)); - self::assertSame(['world', 'bar'], $zipped->at(2)); + static::assertInstanceOf($this->mapClass, $zipped); + static::assertCount(2, $zipped); + static::assertSame(['hello', 'foo'], $zipped->at(1)); + static::assertSame(['world', 'bar'], $zipped->at(2)); } public function testTake(): void { $map = $this->create([]); $rest = $map->take(2); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(0, $rest); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(0, $rest); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); $rest = $map->take(4); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(2, $rest); - self::assertSame($map->toArray(), $rest->toArray()); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(2, $rest); + static::assertSame($map->toArray(), $rest->toArray()); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); $rest = $map->take(1); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(1, $rest); - self::assertSame('bar', $rest->at('foo')); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(1, $rest); + static::assertSame('bar', $rest->at('foo')); } public function testTakeWhile(): void { $map = $this->create([]); - $rest = $map->takeWhile(fn ($v) => false); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(0, $rest); + $rest = $map->takeWhile(static fn ($v) => false); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(0, $rest); $map = $this->create([]); - $rest = $map->takeWhile(fn ($v) => true); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(0, $rest); + $rest = $map->takeWhile(static fn ($v) => true); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(0, $rest); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); - $rest = $map->takeWhile(fn ($v) => true); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(2, $rest); - self::assertSame($map->toArray(), $rest->toArray()); + $rest = $map->takeWhile(static fn ($v) => true); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(2, $rest); + static::assertSame($map->toArray(), $rest->toArray()); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); - $rest = $map->takeWhile(fn ($v) => 'bar' === $v); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(1, $rest); - self::assertSame('bar', $rest->at('foo')); + $rest = $map->takeWhile(static fn ($v) => 'bar' === $v); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(1, $rest); + static::assertSame('bar', $rest->at('foo')); } public function testDrop(): void { $map = $this->create([]); $rest = $map->drop(2); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(0, $rest); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(0, $rest); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); $rest = $map->drop(4); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(0, $rest); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(0, $rest); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); $rest = $map->drop(1); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(1, $rest); - self::assertSame('qux', $rest->at('baz')); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(1, $rest); + static::assertSame('qux', $rest->at('baz')); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); $rest = $map->drop(0); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(2, $rest); - self::assertSame($map->toArray(), $rest->toArray()); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(2, $rest); + static::assertSame($map->toArray(), $rest->toArray()); } public function testDropWhile(): void { $map = $this->create([]); - $rest = $map->dropWhile(fn ($v) => true); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(0, $rest); + $rest = $map->dropWhile(static fn ($v) => true); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(0, $rest); $map = $this->create([]); - $rest = $map->dropWhile(fn ($v) => false); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(0, $rest); + $rest = $map->dropWhile(static fn ($v) => false); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(0, $rest); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); - $rest = $map->dropWhile(fn ($v) => true); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(0, $rest); + $rest = $map->dropWhile(static fn ($v) => true); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(0, $rest); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); - $rest = $map->dropWhile(fn ($v) => false); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(2, $rest); - self::assertSame($map->toArray(), $rest->toArray()); + $rest = $map->dropWhile(static fn ($v) => false); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(2, $rest); + static::assertSame($map->toArray(), $rest->toArray()); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); - $rest = $map->dropWhile(fn ($v) => 'bar' === $v); - self::assertInstanceOf($this->mapClass, $rest); - self::assertNotSame($map, $rest); - self::assertCount(1, $rest); - self::assertSame('qux', $rest->at('baz')); + $rest = $map->dropWhile(static fn ($v) => 'bar' === $v); + static::assertInstanceOf($this->mapClass, $rest); + static::assertNotSame($map, $rest); + static::assertCount(1, $rest); + static::assertSame('qux', $rest->at('baz')); } public function testSlice(): void @@ -509,16 +509,16 @@ public function testSlice(): void ]); $slice1 = $map->slice(0, 1); - self::assertInstanceOf($this->mapClass, $slice1); - self::assertNotSame($slice1, $map); - self::assertCount(1, $slice1); - self::assertSame('foo', $slice1->at(0)); + static::assertInstanceOf($this->mapClass, $slice1); + static::assertNotSame($slice1, $map); + static::assertCount(1, $slice1); + static::assertSame('foo', $slice1->at(0)); $slice2 = $map->slice(2, 4); - self::assertInstanceOf($this->mapClass, $slice1); - self::assertNotSame($slice2, $map); - self::assertCount(4, $slice2); - self::assertSame([ + static::assertInstanceOf($this->mapClass, $slice1); + static::assertNotSame($slice2, $map); + static::assertCount(4, $slice2); + static::assertSame([ 2 => 'bar', 3 => 'bar', 4 => 'baz', @@ -533,8 +533,8 @@ public function testAt(): void 'bar' => 'world', ]); - self::assertSame('hello', $map->at('foo')); - self::assertSame('world', $map->at('bar')); + static::assertSame('hello', $map->at('foo')); + static::assertSame('world', $map->at('bar')); $this->expectException(InvariantViolationException::class); $this->expectExceptionMessage('Key (baz) is out-of-bounds.'); @@ -549,9 +549,9 @@ public function testContains(): void 'bar' => 'world', ]); - self::assertTrue($map->contains('foo')); - self::assertTrue($map->contains('bar')); - self::assertFalse($map->contains('baz')); + static::assertTrue($map->contains('foo')); + static::assertTrue($map->contains('bar')); + static::assertFalse($map->contains('baz')); } public function testGet(): void @@ -561,9 +561,9 @@ public function testGet(): void 'bar' => 'world', ]); - self::assertSame('hello', $map->get('foo')); - self::assertSame('world', $map->get('bar')); - self::assertNull($map->get('baz')); + static::assertSame('hello', $map->get('foo')); + static::assertSame('world', $map->get('bar')); + static::assertNull($map->get('baz')); } /** diff --git a/tests/Psl/Collection/AbstractVectorTest.php b/tests/Psl/Collection/AbstractVectorTest.php index b48102a4..ee29f954 100644 --- a/tests/Psl/Collection/AbstractVectorTest.php +++ b/tests/Psl/Collection/AbstractVectorTest.php @@ -24,16 +24,16 @@ abstract class AbstractVectorTest extends TestCase public function testIsEmpty(): void { - self::assertTrue($this->create([])->isEmpty()); - self::assertFalse($this->create(['foo', 'bar'])->isEmpty()); - self::assertEmpty($this->create([null])->isEmpty()); + static::assertTrue($this->create([])->isEmpty()); + static::assertFalse($this->create(['foo', 'bar'])->isEmpty()); + static::assertEmpty($this->create([null])->isEmpty()); } public function testCount(): void { - self::assertCount(0, $this->create([])); - self::assertCount(2, $this->create(['foo', 'bar'])); - self::assertSame(5, $this->create([ + static::assertCount(0, $this->create([])); + static::assertCount(2, $this->create(['foo', 'bar'])); + static::assertSame(5, $this->create([ 'foo', 'bar', 'baz', @@ -48,19 +48,19 @@ public function testValues(): void $values = $vector->values(); - self::assertInstanceOf($this->vectorClass, $values); + static::assertInstanceOf($this->vectorClass, $values); - self::assertCount(3, $values); + static::assertCount(3, $values); - self::assertSame(1, $values->at(0)); - self::assertSame(2, $values->at(1)); - self::assertSame(3, $values->at(2)); + static::assertSame(1, $values->at(0)); + static::assertSame(2, $values->at(1)); + static::assertSame(3, $values->at(2)); $vector = $this->create([]); $values = $vector->values(); - self::assertInstanceOf($this->vectorClass, $values); + static::assertInstanceOf($this->vectorClass, $values); - self::assertCount(0, $values); + static::assertCount(0, $values); } public function testJsonSerialize(): void @@ -81,17 +81,17 @@ public function testKeys(): void ]); $keys = $vector->keys(); - self::assertInstanceOf($this->vectorClass, $keys); - self::assertCount(3, $keys); - self::assertSame(0, $keys->at(0)); - self::assertSame(1, $keys->at(1)); - self::assertSame(2, $keys->at(2)); + static::assertInstanceOf($this->vectorClass, $keys); + static::assertCount(3, $keys); + static::assertSame(0, $keys->at(0)); + static::assertSame(1, $keys->at(1)); + static::assertSame(2, $keys->at(2)); $vector = $this->create([]); $keys = $vector->keys(); - self::assertInstanceOf($this->vectorClass, $keys); - self::assertCount(0, $keys); + static::assertInstanceOf($this->vectorClass, $keys); + static::assertCount(0, $keys); } public function testFilter(): void @@ -103,15 +103,15 @@ public function testFilter(): void 'qux', ]); - $filtered = $vector->filter(fn (string $item) => Str\contains($item, 'b')); + $filtered = $vector->filter(static fn (string $item) => Str\contains($item, 'b')); - self::assertInstanceOf($this->vectorClass, $filtered); - self::assertNotSame($vector, $filtered); - self::assertContains('bar', $filtered); - self::assertContains('baz', $filtered); - self::assertNotContains('foo', $filtered); - self::assertNotContains('qux', $filtered); - self::assertCount(2, $filtered); + static::assertInstanceOf($this->vectorClass, $filtered); + static::assertNotSame($vector, $filtered); + static::assertContains('bar', $filtered); + static::assertContains('baz', $filtered); + static::assertNotContains('foo', $filtered); + static::assertNotContains('qux', $filtered); + static::assertCount(2, $filtered); $vector = $this->create([ 'foo', @@ -120,14 +120,14 @@ public function testFilter(): void 'qux', ]); - $filtered = $vector->filter(fn (string $item) => Str\contains($item, 'hello')); + $filtered = $vector->filter(static fn (string $item) => Str\contains($item, 'hello')); - self::assertInstanceOf($this->vectorClass, $filtered); - self::assertNotContains('bar', $filtered); - self::assertNotContains('baz', $filtered); - self::assertNotContains('foo', $filtered); - self::assertNotContains('qux', $filtered); - self::assertCount(0, $filtered); + static::assertInstanceOf($this->vectorClass, $filtered); + static::assertNotContains('bar', $filtered); + static::assertNotContains('baz', $filtered); + static::assertNotContains('foo', $filtered); + static::assertNotContains('qux', $filtered); + static::assertCount(0, $filtered); } public function testFilterWithKey(): void @@ -139,15 +139,15 @@ public function testFilterWithKey(): void 'qux', ]); - $filtered = $vector->filterWithKey(fn (int $k, string $v) => 'foo' === $v || 3 === $k); + $filtered = $vector->filterWithKey(static fn (int $k, string $v) => 'foo' === $v || 3 === $k); - self::assertInstanceOf($this->vectorClass, $filtered); - self::assertNotSame($vector, $filtered); - self::assertContains('foo', $filtered); - self::assertContains('qux', $filtered); - self::assertNotContains('bar', $filtered); - self::assertNotContains('baz', $filtered); - self::assertCount(2, $filtered); + static::assertInstanceOf($this->vectorClass, $filtered); + static::assertNotSame($vector, $filtered); + static::assertContains('foo', $filtered); + static::assertContains('qux', $filtered); + static::assertNotContains('bar', $filtered); + static::assertNotContains('baz', $filtered); + static::assertCount(2, $filtered); $vector = $this->create([ 'foo', @@ -156,14 +156,14 @@ public function testFilterWithKey(): void 'qux', ]); - $filtered = $vector->filterWithKey(fn (int $k, string $v) => 4 === $k); + $filtered = $vector->filterWithKey(static fn (int $k, string $v) => 4 === $k); - self::assertInstanceOf($this->vectorClass, $filtered); - self::assertNotContains('bar', $filtered); - self::assertNotContains('baz', $filtered); - self::assertNotContains('foo', $filtered); - self::assertNotContains('qux', $filtered); - self::assertCount(0, $filtered); + static::assertInstanceOf($this->vectorClass, $filtered); + static::assertNotContains('bar', $filtered); + static::assertNotContains('baz', $filtered); + static::assertNotContains('foo', $filtered); + static::assertNotContains('qux', $filtered); + static::assertCount(0, $filtered); } public function testMap(): void @@ -175,17 +175,17 @@ public function testMap(): void 'qux', ]); - $mapped = $vector->map(fn (string $item) => Str\uppercase($item)); + $mapped = $vector->map(static fn (string $item) => Str\uppercase($item)); - self::assertInstanceOf($this->vectorClass, $mapped); - self::assertSame([ + static::assertInstanceOf($this->vectorClass, $mapped); + static::assertSame([ 'FOO', 'BAR', 'BAZ', 'QUX', ], $mapped->toArray()); - self::assertNotSame($vector, $mapped); - self::assertCount(4, $mapped); + static::assertNotSame($vector, $mapped); + static::assertCount(4, $mapped); $vector = $this->create([ 'foo', @@ -194,12 +194,12 @@ public function testMap(): void 'qux', ]); - $mapped = $vector->map(fn (string $item) => $item); + $mapped = $vector->map(static fn (string $item) => $item); - self::assertInstanceOf($this->vectorClass, $mapped); - self::assertNotSame($vector, $mapped); - self::assertSame($vector->toArray(), $mapped->toArray()); - self::assertCount(4, $mapped); + static::assertInstanceOf($this->vectorClass, $mapped); + static::assertNotSame($vector, $mapped); + static::assertSame($vector->toArray(), $mapped->toArray()); + static::assertCount(4, $mapped); } public function testMapWithKey(): void @@ -211,17 +211,17 @@ public function testMapWithKey(): void 3 => 'qux', ]); - $mapped = $vector->mapWithKey(fn (int $k, string $v) => Str\format('%s ( %d )', $v, $k)); + $mapped = $vector->mapWithKey(static fn (int $k, string $v) => Str\format('%s ( %d )', $v, $k)); - self::assertInstanceOf($this->vectorClass, $mapped); - self::assertSame([ + static::assertInstanceOf($this->vectorClass, $mapped); + static::assertSame([ 'foo ( 0 )', 'bar ( 1 )', 'baz ( 2 )', 'qux ( 3 )', ], $mapped->toArray()); - self::assertNotSame($vector, $mapped); - self::assertCount(4, $mapped); + static::assertNotSame($vector, $mapped); + static::assertCount(4, $mapped); $vector = $this->create([ 'foo', @@ -230,249 +230,249 @@ public function testMapWithKey(): void 'qux', ]); - $mapped = $vector->mapWithKey(fn (int $k, string $v) => $k); + $mapped = $vector->mapWithKey(static fn (int $k, string $v) => $k); - self::assertInstanceOf($this->vectorClass, $mapped); - self::assertNotSame($vector, $mapped); - self::assertSame($vector->keys()->toArray(), $mapped->toArray()); - self::assertCount(4, $mapped); + static::assertInstanceOf($this->vectorClass, $mapped); + static::assertNotSame($vector, $mapped); + static::assertSame($vector->keys()->toArray(), $mapped->toArray()); + static::assertCount(4, $mapped); - $mapped = $vector->mapWithKey(fn (int $k, string $v) => $v); + $mapped = $vector->mapWithKey(static fn (int $k, string $v) => $v); - self::assertInstanceOf($this->vectorClass, $mapped); - self::assertNotSame($vector, $mapped); - self::assertSame($vector->toArray(), $mapped->toArray()); - self::assertCount(4, $mapped); + static::assertInstanceOf($this->vectorClass, $mapped); + static::assertNotSame($vector, $mapped); + static::assertSame($vector->toArray(), $mapped->toArray()); + static::assertCount(4, $mapped); } public function testFirst(): void { $vector = $this->create([]); - self::assertNull($vector->first()); + static::assertNull($vector->first()); $vector = $this->create([null]); - self::assertNull($vector->first()); + static::assertNull($vector->first()); $vector = $this->create(['foo']); - self::assertSame('foo', $vector->first()); + static::assertSame('foo', $vector->first()); $vector = $this->create(['bar', 'qux']); - self::assertSame('bar', $vector->first()); + static::assertSame('bar', $vector->first()); } public function testFirstKey(): void { $vector = $this->create([]); - self::assertNull($vector->firstKey()); + static::assertNull($vector->firstKey()); $vector = $this->create([null]); - self::assertSame(0, $vector->firstKey()); + static::assertSame(0, $vector->firstKey()); $vector = $this->create(['foo']); - self::assertSame(0, $vector->firstKey()); + static::assertSame(0, $vector->firstKey()); $vector = $this->create(['bar', 'qux']); - self::assertSame(0, $vector->firstKey()); + static::assertSame(0, $vector->firstKey()); } public function testLast(): void { $vector = $this->create([]); - self::assertNull($vector->last()); + static::assertNull($vector->last()); $vector = $this->create([null]); - self::assertNull($vector->last()); + static::assertNull($vector->last()); $vector = $this->create(['foo']); - self::assertSame('foo', $vector->last()); + static::assertSame('foo', $vector->last()); $vector = $this->create(['bar', 'qux']); - self::assertSame('qux', $vector->last()); + static::assertSame('qux', $vector->last()); } public function testLastKey(): void { $vector = $this->create([]); - self::assertNull($vector->lastKey()); + static::assertNull($vector->lastKey()); $vector = $this->create([null]); - self::assertSame(0, $vector->lastKey()); + static::assertSame(0, $vector->lastKey()); $vector = $this->create(['foo']); - self::assertSame(0, $vector->lastKey()); + static::assertSame(0, $vector->lastKey()); $vector = $this->create(['bar', 'qux']); - self::assertSame(1, $vector->lastKey()); + static::assertSame(1, $vector->lastKey()); } public function testLinearSearch(): void { $vector = $this->create([]); - self::assertNull($vector->linearSearch('foo')); + static::assertNull($vector->linearSearch('foo')); $vector = $this->create([ 'foo', 'bar', ]); - self::assertSame(0, $vector->linearSearch('foo')); - self::assertSame(1, $vector->linearSearch('bar')); - self::assertNull($vector->linearSearch('baz')); - self::assertNull($vector->linearSearch('qux')); + static::assertSame(0, $vector->linearSearch('foo')); + static::assertSame(1, $vector->linearSearch('bar')); + static::assertNull($vector->linearSearch('baz')); + static::assertNull($vector->linearSearch('qux')); } public function testZip(): void { $vector = $this->create([]); $zipped = $vector->zip([]); - self::assertInstanceOf($this->vectorClass, $zipped); - self::assertCount(0, $zipped); + static::assertInstanceOf($this->vectorClass, $zipped); + static::assertCount(0, $zipped); $vector = $this->create([]); $zipped = $vector->zip([1, 2]); - self::assertInstanceOf($this->vectorClass, $zipped); - self::assertCount(0, $zipped); + static::assertInstanceOf($this->vectorClass, $zipped); + static::assertCount(0, $zipped); $vector = $this->create(['foo', 'bar']); $zipped = $vector->zip([]); - self::assertInstanceOf($this->vectorClass, $zipped); - self::assertCount(0, $zipped); + static::assertInstanceOf($this->vectorClass, $zipped); + static::assertCount(0, $zipped); $vector = $this->create(['foo', 'bar']); $zipped = $vector->zip(['baz', 'qux']); - self::assertInstanceOf($this->vectorClass, $zipped); - self::assertCount(2, $zipped); - self::assertSame(['foo', 'baz'], $zipped->at(0)); - self::assertSame(['bar', 'qux'], $zipped->at(1)); + static::assertInstanceOf($this->vectorClass, $zipped); + static::assertCount(2, $zipped); + static::assertSame(['foo', 'baz'], $zipped->at(0)); + static::assertSame(['bar', 'qux'], $zipped->at(1)); $vector = $this->create(['foo', 'bar', 'baz', 'qux']); $zipped = $vector->zip(['hello', 'world']); - self::assertInstanceOf($this->vectorClass, $zipped); - self::assertCount(2, $zipped); - self::assertSame(['foo', 'hello'], $zipped->at(0)); - self::assertSame(['bar', 'world'], $zipped->at(1)); + static::assertInstanceOf($this->vectorClass, $zipped); + static::assertCount(2, $zipped); + static::assertSame(['foo', 'hello'], $zipped->at(0)); + static::assertSame(['bar', 'world'], $zipped->at(1)); $vector = $this->create(['hello', 'world']); $zipped = $vector->zip(['foo', 'bar', 'baz', 'qux']); - self::assertInstanceOf($this->vectorClass, $zipped); - self::assertCount(2, $zipped); - self::assertSame(['hello', 'foo'], $zipped->at(0)); - self::assertSame(['world', 'bar'], $zipped->at(1)); + static::assertInstanceOf($this->vectorClass, $zipped); + static::assertCount(2, $zipped); + static::assertSame(['hello', 'foo'], $zipped->at(0)); + static::assertSame(['world', 'bar'], $zipped->at(1)); } public function testTake(): void { $vector = $this->create([]); $rest = $vector->take(2); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(0, $rest); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(0, $rest); $vector = $this->create(['bar', 'qux']); $rest = $vector->take(4); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(2, $rest); - self::assertSame($vector->toArray(), $rest->toArray()); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(2, $rest); + static::assertSame($vector->toArray(), $rest->toArray()); $vector = $this->create(['bar', 'qux']); $rest = $vector->take(1); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(1, $rest); - self::assertSame('bar', $rest->at(0)); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(1, $rest); + static::assertSame('bar', $rest->at(0)); } public function testTakeWhile(): void { $vector = $this->create([]); - $rest = $vector->takeWhile(fn ($v) => false); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(0, $rest); + $rest = $vector->takeWhile(static fn ($v) => false); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(0, $rest); $vector = $this->create([]); - $rest = $vector->takeWhile(fn ($v) => true); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(0, $rest); + $rest = $vector->takeWhile(static fn ($v) => true); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(0, $rest); $vector = $this->create(['bar', 'qux']); - $rest = $vector->takeWhile(fn ($v) => true); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(2, $rest); - self::assertSame($vector->toArray(), $rest->toArray()); + $rest = $vector->takeWhile(static fn ($v) => true); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(2, $rest); + static::assertSame($vector->toArray(), $rest->toArray()); $vector = $this->create(['bar', 'qux']); - $rest = $vector->takeWhile(fn ($v) => 'bar' === $v); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(1, $rest); - self::assertSame('bar', $rest->at(0)); + $rest = $vector->takeWhile(static fn ($v) => 'bar' === $v); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(1, $rest); + static::assertSame('bar', $rest->at(0)); } public function testDrop(): void { $vector = $this->create([]); $rest = $vector->drop(2); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(0, $rest); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(0, $rest); $vector = $this->create(['bar', 'qux']); $rest = $vector->drop(4); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(0, $rest); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(0, $rest); $vector = $this->create(['bar', 'qux']); $rest = $vector->drop(1); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(1, $rest); - self::assertSame('qux', $rest->at(0)); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(1, $rest); + static::assertSame('qux', $rest->at(0)); $vector = $this->create(['bar', 'qux']); $rest = $vector->drop(0); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(2, $rest); - self::assertSame($vector->toArray(), $rest->toArray()); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(2, $rest); + static::assertSame($vector->toArray(), $rest->toArray()); } public function testDropWhile(): void { $vector = $this->create([]); - $rest = $vector->dropWhile(fn ($v) => true); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(0, $rest); + $rest = $vector->dropWhile(static fn ($v) => true); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(0, $rest); $vector = $this->create([]); - $rest = $vector->dropWhile(fn ($v) => false); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(0, $rest); + $rest = $vector->dropWhile(static fn ($v) => false); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(0, $rest); $vector = $this->create(['bar', 'qux']); - $rest = $vector->dropWhile(fn ($v) => true); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(0, $rest); + $rest = $vector->dropWhile(static fn ($v) => true); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(0, $rest); $vector = $this->create(['bar', 'qux']); - $rest = $vector->dropWhile(fn ($v) => false); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(2, $rest); - self::assertSame($vector->toArray(), $rest->toArray()); + $rest = $vector->dropWhile(static fn ($v) => false); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(2, $rest); + static::assertSame($vector->toArray(), $rest->toArray()); $vector = $this->create(['bar', 'qux']); - $rest = $vector->dropWhile(fn ($v) => 'bar' === $v); - self::assertInstanceOf($this->vectorClass, $rest); - self::assertNotSame($vector, $rest); - self::assertCount(1, $rest); - self::assertSame('qux', $rest->at(0)); + $rest = $vector->dropWhile(static fn ($v) => 'bar' === $v); + static::assertInstanceOf($this->vectorClass, $rest); + static::assertNotSame($vector, $rest); + static::assertCount(1, $rest); + static::assertSame('qux', $rest->at(0)); } public function testSlice(): void @@ -489,16 +489,16 @@ public function testSlice(): void ]); $slice1 = $vector->slice(0, 1); - self::assertInstanceOf($this->vectorClass, $slice1); - self::assertNotSame($slice1, $vector); - self::assertCount(1, $slice1); - self::assertSame('foo', $slice1->at(0)); + static::assertInstanceOf($this->vectorClass, $slice1); + static::assertNotSame($slice1, $vector); + static::assertCount(1, $slice1); + static::assertSame('foo', $slice1->at(0)); $slice2 = $vector->slice(2, 4); - self::assertInstanceOf($this->vectorClass, $slice1); - self::assertNotSame($slice2, $vector); - self::assertCount(4, $slice2); - self::assertSame([ + static::assertInstanceOf($this->vectorClass, $slice1); + static::assertNotSame($slice2, $vector); + static::assertCount(4, $slice2); + static::assertSame([ 'bar', 'bar', 'baz', @@ -513,8 +513,8 @@ public function testAt(): void 'world', ]); - self::assertSame('hello', $vector->at(0)); - self::assertSame('world', $vector->at(1)); + static::assertSame('hello', $vector->at(0)); + static::assertSame('world', $vector->at(1)); $this->expectException(InvariantViolationException::class); $this->expectExceptionMessage('Key (2) is out-of-bounds.'); @@ -529,9 +529,9 @@ public function testContains(): void 'world', ]); - self::assertTrue($vector->contains(0)); - self::assertTrue($vector->contains(1)); - self::assertFalse($vector->contains(2)); + static::assertTrue($vector->contains(0)); + static::assertTrue($vector->contains(1)); + static::assertFalse($vector->contains(2)); } public function testGet(): void @@ -541,9 +541,9 @@ public function testGet(): void 'world', ]); - self::assertSame('hello', $vector->get(0)); - self::assertSame('world', $vector->get(1)); - self::assertNull($vector->get(2)); + static::assertSame('hello', $vector->get(0)); + static::assertSame('world', $vector->get(1)); + static::assertNull($vector->get(2)); } /** diff --git a/tests/Psl/Collection/MutableMapTest.php b/tests/Psl/Collection/MutableMapTest.php index 145eed98..eb94b6bc 100644 --- a/tests/Psl/Collection/MutableMapTest.php +++ b/tests/Psl/Collection/MutableMapTest.php @@ -29,8 +29,8 @@ public function testClear(): void $map = $this->create(['foo' => 'bar']); $cleared = $map->clear(); - self::assertSame($cleared, $map); - self::assertCount(0, $map); + static::assertSame($cleared, $map); + static::assertCount(0, $map); } public function testSet(): void @@ -46,11 +46,11 @@ public function testSet(): void ->set('bar', 'bar') ->set('baz', 'baz'); - self::assertSame($modified, $map); + static::assertSame($modified, $map); - self::assertSame('foo', $map->at('foo')); - self::assertSame('bar', $map->at('bar')); - self::assertSame('baz', $map->at('baz')); + static::assertSame('foo', $map->at('foo')); + static::assertSame('bar', $map->at('bar')); + static::assertSame('baz', $map->at('baz')); $this->expectException(InvariantViolationException::class); $this->expectExceptionMessage('Key (qux) is out-of-bounds.'); @@ -72,11 +72,11 @@ public function testSetAll(): void 'baz' => 'baz', ])); - self::assertSame($modified, $map); + static::assertSame($modified, $map); - self::assertSame('foo', $map->at('foo')); - self::assertSame('bar', $map->at('bar')); - self::assertSame('baz', $map->at('baz')); + static::assertSame('foo', $map->at('foo')); + static::assertSame('bar', $map->at('bar')); + static::assertSame('baz', $map->at('baz')); $this->expectException(InvariantViolationException::class); $this->expectExceptionMessage('Key (qux) is out-of-bounds.'); @@ -97,12 +97,12 @@ public function testAdd(): void ->add('baz', 'baz') ->add('qux', 'qux'); - self::assertSame($modified, $map); + static::assertSame($modified, $map); - self::assertSame('foo', $map->at('foo')); - self::assertSame('bar', $map->at('bar')); - self::assertSame('baz', $map->at('baz')); - self::assertSame('qux', $map->at('qux')); + static::assertSame('foo', $map->at('foo')); + static::assertSame('bar', $map->at('bar')); + static::assertSame('baz', $map->at('baz')); + static::assertSame('qux', $map->at('qux')); } public function testAddAll(): void @@ -119,12 +119,12 @@ public function testAddAll(): void 'qux' => 'qux', ]); - self::assertSame($modified, $map); + static::assertSame($modified, $map); - self::assertSame('foo', $map->at('foo')); - self::assertSame('bar', $map->at('bar')); - self::assertSame('baz', $map->at('baz')); - self::assertSame('qux', $map->at('qux')); + static::assertSame('foo', $map->at('foo')); + static::assertSame('bar', $map->at('bar')); + static::assertSame('baz', $map->at('baz')); + static::assertSame('qux', $map->at('qux')); } public function testRemove(): void @@ -139,11 +139,11 @@ public function testRemove(): void ->remove('foo') ->remove('bar'); - self::assertSame($modified, $map); - self::assertCount(1, $map); - self::assertSame('qux', $map->get('baz')); - self::assertNull($map->get('foo')); - self::assertNull($map->get('bar')); + static::assertSame($modified, $map); + static::assertCount(1, $map); + static::assertSame('qux', $map->get('baz')); + static::assertNull($map->get('foo')); + static::assertNull($map->get('bar')); } /** diff --git a/tests/Psl/Collection/MutableVectorTest.php b/tests/Psl/Collection/MutableVectorTest.php index 88cc2e88..31960b07 100644 --- a/tests/Psl/Collection/MutableVectorTest.php +++ b/tests/Psl/Collection/MutableVectorTest.php @@ -23,8 +23,8 @@ public function testClear(): void $vector = $this->create(['foo', 'bar']); $cleared = $vector->clear(); - self::assertSame($cleared, $vector); - self::assertCount(0, $vector); + static::assertSame($cleared, $vector); + static::assertCount(0, $vector); } public function testSet(): void @@ -40,11 +40,11 @@ public function testSet(): void ->set(1, 'bar') ->set(2, 'baz'); - self::assertSame($modified, $vector); + static::assertSame($modified, $vector); - self::assertSame('foo', $vector->at(0)); - self::assertSame('bar', $vector->at(1)); - self::assertSame('baz', $vector->at(2)); + static::assertSame('foo', $vector->at(0)); + static::assertSame('bar', $vector->at(1)); + static::assertSame('baz', $vector->at(2)); $this->expectException(InvariantViolationException::class); $this->expectExceptionMessage('Key (3) is out-of-bounds.'); @@ -66,11 +66,11 @@ public function testSetAll(): void 2 => 'baz', ])); - self::assertSame($modified, $vector); + static::assertSame($modified, $vector); - self::assertSame('foo', $vector->at(0)); - self::assertSame('bar', $vector->at(1)); - self::assertSame('baz', $vector->at(2)); + static::assertSame('foo', $vector->at(0)); + static::assertSame('bar', $vector->at(1)); + static::assertSame('baz', $vector->at(2)); $this->expectException(InvariantViolationException::class); $this->expectExceptionMessage('Key (3) is out-of-bounds.'); @@ -89,14 +89,14 @@ public function testAdd(): void ->add('hello') ->add('world'); - self::assertSame($modified, $vector); + static::assertSame($modified, $vector); - self::assertSame('foo', $vector->at(0)); - self::assertSame('bar', $vector->at(1)); - self::assertSame('baz', $vector->at(2)); - self::assertSame('qux', $vector->at(3)); - self::assertSame('hello', $vector->at(4)); - self::assertSame('world', $vector->at(5)); + static::assertSame('foo', $vector->at(0)); + static::assertSame('bar', $vector->at(1)); + static::assertSame('baz', $vector->at(2)); + static::assertSame('qux', $vector->at(3)); + static::assertSame('hello', $vector->at(4)); + static::assertSame('world', $vector->at(5)); } public function testAddAll(): void @@ -112,14 +112,14 @@ public function testAddAll(): void 'world', ])); - self::assertSame($modified, $vector); + static::assertSame($modified, $vector); - self::assertSame('foo', $vector->at(0)); - self::assertSame('bar', $vector->at(1)); - self::assertSame('baz', $vector->at(2)); - self::assertSame('qux', $vector->at(3)); - self::assertSame('hello', $vector->at(4)); - self::assertSame('world', $vector->at(5)); + static::assertSame('foo', $vector->at(0)); + static::assertSame('bar', $vector->at(1)); + static::assertSame('baz', $vector->at(2)); + static::assertSame('qux', $vector->at(3)); + static::assertSame('hello', $vector->at(4)); + static::assertSame('world', $vector->at(5)); } public function testRemove(): void @@ -134,9 +134,9 @@ public function testRemove(): void ->remove(0) ->remove(0); - self::assertSame($modified, $vector); - self::assertCount(1, $vector); - self::assertSame('baz', $vector->get(0)); + static::assertSame($modified, $vector); + static::assertCount(1, $vector); + static::assertSame('baz', $vector->get(0)); } /** diff --git a/tests/Psl/DataStructure/PriorityQueueTest.php b/tests/Psl/DataStructure/PriorityQueueTest.php index 99721552..44948e7b 100644 --- a/tests/Psl/DataStructure/PriorityQueueTest.php +++ b/tests/Psl/DataStructure/PriorityQueueTest.php @@ -17,12 +17,12 @@ public function testEnqueueAndDequeue(): void $queue->enqueue('hey', 2); $queue->enqueue('hello', 3); - self::assertCount(3, $queue); - self::assertSame('hello', $queue->dequeue()); - self::assertCount(2, $queue); - self::assertSame('hey', $queue->dequeue()); - self::assertCount(1, $queue); - self::assertSame('hi', $queue->dequeue()); + static::assertCount(3, $queue); + static::assertSame('hello', $queue->dequeue()); + static::assertCount(2, $queue); + static::assertSame('hey', $queue->dequeue()); + static::assertCount(1, $queue); + static::assertSame('hi', $queue->dequeue()); } public function testMultipleNodesWithSamePriority(): void @@ -32,12 +32,12 @@ public function testMultipleNodesWithSamePriority(): void $queue->enqueue('hey', 1); $queue->enqueue('hello', 1); - self::assertCount(3, $queue); - self::assertSame('hi', $queue->dequeue()); - self::assertCount(2, $queue); - self::assertSame('hey', $queue->dequeue()); - self::assertCount(1, $queue); - self::assertSame('hello', $queue->dequeue()); + static::assertCount(3, $queue); + static::assertSame('hi', $queue->dequeue()); + static::assertCount(2, $queue); + static::assertSame('hey', $queue->dequeue()); + static::assertCount(1, $queue); + static::assertSame('hello', $queue->dequeue()); } public function testPeekDoesNotRemoveTheNode(): void @@ -47,18 +47,18 @@ public function testPeekDoesNotRemoveTheNode(): void $queue->enqueue('hey', 2); $queue->enqueue('hello', 3); - self::assertCount(3, $queue); - self::assertSame('hello', $queue->peek()); - self::assertCount(3, $queue); - self::assertSame('hello', $queue->peek()); + static::assertCount(3, $queue); + static::assertSame('hello', $queue->peek()); + static::assertCount(3, $queue); + static::assertSame('hello', $queue->peek()); } public function testPeekReturnsNullWhenTheQueueIsEmpty(): void { $queue = new DataStructure\PriorityQueue(); - self::assertCount(0, $queue); - self::assertNull($queue->peek()); + static::assertCount(0, $queue); + static::assertNull($queue->peek()); } public function testPullDoesRemoveTheNode(): void @@ -68,22 +68,22 @@ public function testPullDoesRemoveTheNode(): void $queue->enqueue('hey', 2); $queue->enqueue('hello', 3); - self::assertCount(3, $queue); - self::assertSame('hello', $queue->pull()); - self::assertCount(2, $queue); - self::assertSame('hey', $queue->pull()); - self::assertCount(1, $queue); - self::assertSame('hi', $queue->pull()); - self::assertCount(0, $queue); - self::assertNull($queue->pull()); + static::assertCount(3, $queue); + static::assertSame('hello', $queue->pull()); + static::assertCount(2, $queue); + static::assertSame('hey', $queue->pull()); + static::assertCount(1, $queue); + static::assertSame('hi', $queue->pull()); + static::assertCount(0, $queue); + static::assertNull($queue->pull()); } public function testPullReturnsNullWhenTheQueueIsEmpty(): void { $queue = new DataStructure\PriorityQueue(); - self::assertCount(0, $queue); - self::assertNull($queue->pull()); + static::assertCount(0, $queue); + static::assertNull($queue->pull()); } public function testDequeueThrowsWhenTheQueueIsEmpty(): void diff --git a/tests/Psl/DataStructure/QueueTest.php b/tests/Psl/DataStructure/QueueTest.php index 2c139895..8d6673e7 100644 --- a/tests/Psl/DataStructure/QueueTest.php +++ b/tests/Psl/DataStructure/QueueTest.php @@ -4,9 +4,9 @@ namespace Psl\DataStructure; +use PHPUnit\Framework\TestCase; use Psl; use Psl\DataStructure; -use PHPUnit\Framework\TestCase; final class QueueTest extends TestCase { @@ -17,12 +17,12 @@ public function testEnqueueAndDequeue(): void $queue->enqueue('hey'); $queue->enqueue('hi'); - self::assertCount(3, $queue); - self::assertSame('hello', $queue->dequeue()); - self::assertCount(2, $queue); - self::assertSame('hey', $queue->dequeue()); - self::assertCount(1, $queue); - self::assertSame('hi', $queue->dequeue()); + static::assertCount(3, $queue); + static::assertSame('hello', $queue->dequeue()); + static::assertCount(2, $queue); + static::assertSame('hey', $queue->dequeue()); + static::assertCount(1, $queue); + static::assertSame('hi', $queue->dequeue()); } public function testPeekDoesNotRemoveTheNode(): void @@ -32,18 +32,18 @@ public function testPeekDoesNotRemoveTheNode(): void $queue->enqueue('hey'); $queue->enqueue('hi'); - self::assertCount(3, $queue); - self::assertSame('hello', $queue->peek()); - self::assertCount(3, $queue); - self::assertSame('hello', $queue->peek()); + static::assertCount(3, $queue); + static::assertSame('hello', $queue->peek()); + static::assertCount(3, $queue); + static::assertSame('hello', $queue->peek()); } public function testPeekReturnsNullWhenTheQueueIsEmpty(): void { $queue = new DataStructure\Queue(); - self::assertCount(0, $queue); - self::assertNull($queue->peek()); + static::assertCount(0, $queue); + static::assertNull($queue->peek()); } public function testPullDoesRemoveTheNode(): void @@ -53,22 +53,22 @@ public function testPullDoesRemoveTheNode(): void $queue->enqueue('hey'); $queue->enqueue('hi'); - self::assertCount(3, $queue); - self::assertSame('hello', $queue->pull()); - self::assertCount(2, $queue); - self::assertSame('hey', $queue->pull()); - self::assertCount(1, $queue); - self::assertSame('hi', $queue->pull()); - self::assertCount(0, $queue); - self::assertNull($queue->pull()); + static::assertCount(3, $queue); + static::assertSame('hello', $queue->pull()); + static::assertCount(2, $queue); + static::assertSame('hey', $queue->pull()); + static::assertCount(1, $queue); + static::assertSame('hi', $queue->pull()); + static::assertCount(0, $queue); + static::assertNull($queue->pull()); } public function testPullReturnsNullWhenTheQueueIsEmpty(): void { $queue = new DataStructure\Queue(); - self::assertCount(0, $queue); - self::assertNull($queue->pull()); + static::assertCount(0, $queue); + static::assertNull($queue->pull()); } public function testDequeueThrowsWhenTheQueueIsEmpty(): void diff --git a/tests/Psl/DataStructure/StackTest.php b/tests/Psl/DataStructure/StackTest.php index da46d854..fc8e4a53 100644 --- a/tests/Psl/DataStructure/StackTest.php +++ b/tests/Psl/DataStructure/StackTest.php @@ -4,9 +4,9 @@ namespace Psl\Tests\DataStructure; +use PHPUnit\Framework\TestCase; use Psl; use Psl\DataStructure\Stack; -use PHPUnit\Framework\TestCase; final class StackTest extends TestCase { @@ -17,27 +17,27 @@ public function testPushAndPop(): void $stack->push('hey'); $stack->push('hi'); - self::assertCount(3, $stack); + static::assertCount(3, $stack); - self::assertSame('hi', $stack->peek()); + static::assertSame('hi', $stack->peek()); - self::assertSame('hi', $stack->pop()); - self::assertSame('hey', $stack->pop()); - self::assertSame('hello', $stack->pop()); + static::assertSame('hi', $stack->pop()); + static::assertSame('hey', $stack->pop()); + static::assertSame('hello', $stack->pop()); - self::assertNull($stack->pull()); + static::assertNull($stack->pull()); } public function testPeek(): void { $stack = new Stack(); - self::assertNull($stack->peek()); + static::assertNull($stack->peek()); $stack->push('hello'); - self::assertNotNull($stack->peek()); - self::assertSame('hello', $stack->peek()); + static::assertNotNull($stack->peek()); + static::assertSame('hello', $stack->peek()); } public function testPopThrowsForEmptyStack(): void @@ -45,7 +45,7 @@ public function testPopThrowsForEmptyStack(): void $stack = new Stack(); $stack->push('hello'); - self::assertSame('hello', $stack->pop()); + static::assertSame('hello', $stack->pop()); $this->expectException(Psl\Exception\InvariantViolationException::class); $this->expectExceptionMessage('Cannot pop an item from an empty Stack.'); @@ -58,16 +58,16 @@ public function testPullReturnsNullForEmptyStack(): void $stack = new Stack(); $stack->push('hello'); - self::assertSame('hello', $stack->pull()); - self::assertNull($stack->pull()); + static::assertSame('hello', $stack->pull()); + static::assertNull($stack->pull()); } public function testCount(): void { $stack = new Stack(); - self::assertSame(0, $stack->count()); + static::assertSame(0, $stack->count()); $stack->push('hello'); - self::assertSame(1, $stack->count()); + static::assertSame(1, $stack->count()); } } diff --git a/tests/Psl/Env/ArgsTest.php b/tests/Psl/Env/ArgsTest.php index 111181f8..f12575c7 100644 --- a/tests/Psl/Env/ArgsTest.php +++ b/tests/Psl/Env/ArgsTest.php @@ -11,6 +11,6 @@ final class ArgsTest extends TestCase { public function testArgs(): void { - self::assertSame($GLOBALS['argv'], Env\args()); + static::assertSame($GLOBALS['argv'], Env\args()); } } diff --git a/tests/Psl/Env/CurrentDirTest.php b/tests/Psl/Env/CurrentDirTest.php index 74c459b2..900f00ce 100644 --- a/tests/Psl/Env/CurrentDirTest.php +++ b/tests/Psl/Env/CurrentDirTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Env; -class CurrentDirTest extends TestCase +final class CurrentDirTest extends TestCase { public function testCurrentDir(): void { - self::assertSame(getcwd(), Env\current_dir()); + static::assertSame(getcwd(), Env\current_dir()); Env\set_current_dir(__DIR__); - self::assertSame(__DIR__, Env\current_dir()); + static::assertSame(__DIR__, Env\current_dir()); } } diff --git a/tests/Psl/Env/CurrentExecTest.php b/tests/Psl/Env/CurrentExecTest.php index 50d3c678..f0a25618 100644 --- a/tests/Psl/Env/CurrentExecTest.php +++ b/tests/Psl/Env/CurrentExecTest.php @@ -16,6 +16,6 @@ public function testCurrentExe(): void $phpunit = __DIR__ . '/../../../vendor/phpunit/phpunit/phpunit'; $phpunit = realpath($phpunit); - self::assertSame($phpunit, Env\current_exec()); + static::assertSame($phpunit, Env\current_exec()); } } diff --git a/tests/Psl/Env/GetVarTest.php b/tests/Psl/Env/GetVarTest.php index d23caad7..0bcec31e 100644 --- a/tests/Psl/Env/GetVarTest.php +++ b/tests/Psl/Env/GetVarTest.php @@ -7,18 +7,18 @@ use PHPUnit\Framework\TestCase; use Psl\Env; -class GetVarTest extends TestCase +final class GetVarTest extends TestCase { /** * @backupGlobals */ public function testGetVar(): void { - self::assertNull(Env\get_var('FOO')); + static::assertNull(Env\get_var('FOO')); Env\set_var('FOO', 'BAR'); - self::assertSame('BAR', Env\get_var('FOO')); + static::assertSame('BAR', Env\get_var('FOO')); Env\remove_var('FOO'); } diff --git a/tests/Psl/Env/GetVarsTest.php b/tests/Psl/Env/GetVarsTest.php index b6f8c11b..18be2781 100644 --- a/tests/Psl/Env/GetVarsTest.php +++ b/tests/Psl/Env/GetVarsTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Env; -class GetVarsTest extends TestCase +final class GetVarsTest extends TestCase { /** * @backupGlobals @@ -16,12 +16,12 @@ public function testGetVars(): void { $expected = getenv(); - self::assertSame($expected, Env\get_vars()); + static::assertSame($expected, Env\get_vars()); Env\set_var('FOO', 'BAR'); - self::assertNotSame($expected, Env\get_vars()); - self::assertSame(getenv(), Env\get_vars()); + static::assertNotSame($expected, Env\get_vars()); + static::assertSame(getenv(), Env\get_vars()); Env\remove_var('FOO'); } diff --git a/tests/Psl/Env/JoinPathsTest.php b/tests/Psl/Env/JoinPathsTest.php index 3e50ca23..98eb06a2 100644 --- a/tests/Psl/Env/JoinPathsTest.php +++ b/tests/Psl/Env/JoinPathsTest.php @@ -8,11 +8,11 @@ use Psl\Env; use Psl\Str; -class JoinPathsTest extends TestCase +final class JoinPathsTest extends TestCase { public function testJoinPaths(): void { - self::assertSame(Str\format('/home/azjezz%s/tmp', PATH_SEPARATOR), Env\join_paths('/home/azjezz', '/tmp')); - self::assertSame('/home/azjezz', Env\join_paths('/home/azjezz')); + static::assertSame(Str\format('/home/azjezz%s/tmp', PATH_SEPARATOR), Env\join_paths('/home/azjezz', '/tmp')); + static::assertSame('/home/azjezz', Env\join_paths('/home/azjezz')); } } diff --git a/tests/Psl/Env/RemoveVarTest.php b/tests/Psl/Env/RemoveVarTest.php index 273eb6c9..aa26e8be 100644 --- a/tests/Psl/Env/RemoveVarTest.php +++ b/tests/Psl/Env/RemoveVarTest.php @@ -8,22 +8,22 @@ use Psl\Env; use Psl\Exception\InvariantViolationException; -class RemoveVarTest extends TestCase +final class RemoveVarTest extends TestCase { /** * @backupGlobals */ public function testRemoveVar(): void { - self::assertNull(Env\get_var('FOO')); + static::assertNull(Env\get_var('FOO')); Env\set_var('FOO', 'BAR'); - self::assertSame('BAR', Env\get_var('FOO')); + static::assertSame('BAR', Env\get_var('FOO')); Env\remove_var('FOO'); - self::assertNull(Env\get_var('FOO')); + static::assertNull(Env\get_var('FOO')); } public function testRemoveVarThrowsIfTheKeyIsInvalid(): void diff --git a/tests/Psl/Env/SplitPathsTest.php b/tests/Psl/Env/SplitPathsTest.php index 587b1f5b..3e15bda1 100644 --- a/tests/Psl/Env/SplitPathsTest.php +++ b/tests/Psl/Env/SplitPathsTest.php @@ -8,12 +8,12 @@ use Psl\Env; use Psl\Str; -class SplitPathsTest extends TestCase +final class SplitPathsTest extends TestCase { public function testSplitPaths(): void { - self::assertSame(['/home/azjezz', '/tmp'], Env\split_paths(Str\format('/home/azjezz%s/tmp', PATH_SEPARATOR))); - self::assertSame(['/home/azjezz', '/tmp'], Env\split_paths(Env\join_paths('/home/azjezz', '/tmp'))); - self::assertSame(['/home/azjezz'], Env\split_paths('/home/azjezz')); + static::assertSame(['/home/azjezz', '/tmp'], Env\split_paths(Str\format('/home/azjezz%s/tmp', PATH_SEPARATOR))); + static::assertSame(['/home/azjezz', '/tmp'], Env\split_paths(Env\join_paths('/home/azjezz', '/tmp'))); + static::assertSame(['/home/azjezz'], Env\split_paths('/home/azjezz')); } } diff --git a/tests/Psl/Env/TempDirTest.php b/tests/Psl/Env/TempDirTest.php index 73b0d5cb..15a255f1 100644 --- a/tests/Psl/Env/TempDirTest.php +++ b/tests/Psl/Env/TempDirTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Env; -class TempDirTest extends TestCase +final class TempDirTest extends TestCase { public function testTempDir(): void { diff --git a/tests/Psl/Fun/AfterTest.php b/tests/Psl/Fun/AfterTest.php index 5e27dcd7..3b0f3b80 100644 --- a/tests/Psl/Fun/AfterTest.php +++ b/tests/Psl/Fun/AfterTest.php @@ -13,20 +13,20 @@ final class AfterTest extends TestCase public function testItCombinesAFunctionToExecuteAFunctionAfterAnotherFunction(): void { $x = Fun\after( - fn (string $x): string => $x . ' world', - fn (string $z): string => $z . '!!' + static fn (string $x): string => $x . ' world', + static fn (string $z): string => $z . '!!' ); - self::assertSame('Hello world!!', $x('Hello')); + static::assertSame('Hello world!!', $x('Hello')); } public function testItCombinesAFunctionThatDealWithDifferentTypes(): void { $x = Fun\after( - fn (string $x): int => Str\length($x), - fn (int $z): string => $z . '!' + static fn (string $x): int => Str\length($x), + static fn (int $z): string => $z . '!' ); - self::assertSame('5!', $x('Hello')); + static::assertSame('5!', $x('Hello')); } } diff --git a/tests/Psl/Fun/IdentityTest.php b/tests/Psl/Fun/IdentityTest.php index bd037a9d..d52f3783 100644 --- a/tests/Psl/Fun/IdentityTest.php +++ b/tests/Psl/Fun/IdentityTest.php @@ -14,6 +14,6 @@ public function testIdentity(): void $expected = 'x'; $identity = Fun\identity(); - self::assertSame($expected, $identity($expected)); + static::assertSame($expected, $identity($expected)); } } diff --git a/tests/Psl/Fun/PipeTest.php b/tests/Psl/Fun/PipeTest.php index b98c7f6a..fb696b54 100644 --- a/tests/Psl/Fun/PipeTest.php +++ b/tests/Psl/Fun/PipeTest.php @@ -13,28 +13,28 @@ final class PipeTest extends TestCase public function testItCombinesMultipleFunctionToExecutesInOrder(): void { $x = Fun\pipe( - fn (string $x): string => $x . ' world', - fn (string $y): string => $y . '?', - fn (string $z): string => $z . '!', + static fn (string $x): string => $x . ' world', + static fn (string $y): string => $y . '?', + static fn (string $z): string => $z . '!', ); - self::assertSame('Hello world?!', $x('Hello')); + static::assertSame('Hello world?!', $x('Hello')); } public function testItCombinesMultipleFunctionsThatDealWithDifferentTypes(): void { $x = Fun\pipe( - fn (string $x): int => Str\length($x), - fn (int $y): string => $y . '!' + static fn (string $x): int => Str\length($x), + static fn (int $y): string => $y . '!' ); - self::assertSame('5!', $x('Hello')); + static::assertSame('5!', $x('Hello')); } public function testItCanCreateAnEmptyCombination(): void { $x = Fun\pipe(); - self::assertSame('Hello', $x('Hello')); + static::assertSame('Hello', $x('Hello')); } } diff --git a/tests/Psl/Fun/RethrowTest.php b/tests/Psl/Fun/RethrowTest.php index ae4d98ac..62061163 100644 --- a/tests/Psl/Fun/RethrowTest.php +++ b/tests/Psl/Fun/RethrowTest.php @@ -4,6 +4,7 @@ namespace Psl\Tests\Fun; +use Exception; use PHPUnit\Framework\TestCase; use Psl\Fun; @@ -11,7 +12,7 @@ final class RethrowTest extends TestCase { public function testRethrow(): void { - $exception = new \Exception('foo'); + $exception = new Exception('foo'); $rethrow = Fun\rethrow(); $this->expectExceptionObject($exception); diff --git a/tests/Psl/Fun/WhenTest.php b/tests/Psl/Fun/WhenTest.php index 46a76155..8abe2889 100644 --- a/tests/Psl/Fun/WhenTest.php +++ b/tests/Psl/Fun/WhenTest.php @@ -17,7 +17,7 @@ public function testItRunsLeftFunction(): void static fn(string $name): string => 'Hello ' . $name . '!' ); - self::assertSame('Bonjour Jos!', $greet('Jos')); + static::assertSame('Bonjour Jos!', $greet('Jos')); } public function testItRunsRightfunction(): void @@ -28,6 +28,6 @@ public function testItRunsRightfunction(): void static fn(string $name): string => 'Hello ' . $name . '!' ); - self::assertSame('Hello World!', $greet('World')); + static::assertSame('Hello World!', $greet('World')); } } diff --git a/tests/Psl/InvariantTest.php b/tests/Psl/InvariantTest.php index 5656083d..943f6740 100644 --- a/tests/Psl/InvariantTest.php +++ b/tests/Psl/InvariantTest.php @@ -8,7 +8,7 @@ use Psl; use Psl\Exception\InvariantViolationException; -class InvariantTest extends TestCase +final class InvariantTest extends TestCase { public function testInvariant(): void { diff --git a/tests/Psl/Iter/AllTest.php b/tests/Psl/Iter/AllTest.php index 403fb63d..473e840e 100644 --- a/tests/Psl/Iter/AllTest.php +++ b/tests/Psl/Iter/AllTest.php @@ -7,29 +7,29 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class AllTest extends TestCase +final class AllTest extends TestCase { /** * @dataProvider provideData */ public function testAll(bool $expected, iterable $iterable, callable $predicate): void { - self::assertSame($expected, Iter\all($iterable, $predicate)); + static::assertSame($expected, Iter\all($iterable, $predicate)); } public function provideData(): iterable { - yield [false, [false, true, true], fn (bool $value): bool => $value]; - yield [false, [false, true, true], fn (bool $value): bool => !$value]; - yield [true, [true, true, true], fn (bool $value): bool => $value]; - yield [false, [true, true, true], fn (bool $value): bool => !$value]; - yield [false, [false, false, false], fn (bool $value): bool => $value]; - yield [true, [false, false, false], fn (bool $value): bool => !$value]; - yield [true, [false, false, false], fn (bool $value): bool => true]; - yield [false, [false, false, false], fn (bool $value): bool => false]; - yield [false, [1, 2, 3], fn (int $i): bool => $i > 3]; - yield [true, [4, 5, 6], fn (int $i): bool => $i > 3]; - yield [false, [1, 2, 3, 4, 5, 6], fn (int $i): bool => $i > 3]; - yield [true, [], fn (bool $value): bool => false]; + yield [false, [false, true, true], static fn (bool $value): bool => $value]; + yield [false, [false, true, true], static fn (bool $value): bool => !$value]; + yield [true, [true, true, true], static fn (bool $value): bool => $value]; + yield [false, [true, true, true], static fn (bool $value): bool => !$value]; + yield [false, [false, false, false], static fn (bool $value): bool => $value]; + yield [true, [false, false, false], static fn (bool $value): bool => !$value]; + yield [true, [false, false, false], static fn (bool $value): bool => true]; + yield [false, [false, false, false], static fn (bool $value): bool => false]; + yield [false, [1, 2, 3], static fn (int $i): bool => $i > 3]; + yield [true, [4, 5, 6], static fn (int $i): bool => $i > 3]; + yield [false, [1, 2, 3, 4, 5, 6], static fn (int $i): bool => $i > 3]; + yield [true, [], static fn (bool $value): bool => false]; } } diff --git a/tests/Psl/Iter/AnyTest.php b/tests/Psl/Iter/AnyTest.php index e2fb1777..bb874258 100644 --- a/tests/Psl/Iter/AnyTest.php +++ b/tests/Psl/Iter/AnyTest.php @@ -7,29 +7,29 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class AnyTest extends TestCase +final class AnyTest extends TestCase { /** * @dataProvider provideData */ public function testAny(bool $expected, iterable $iterable, callable $predicate): void { - self::assertSame($expected, Iter\any($iterable, $predicate)); + static::assertSame($expected, Iter\any($iterable, $predicate)); } public function provideData(): iterable { - yield [true, [false, true, true], fn (bool $value): bool => $value]; - yield [true, [false, true, true], fn (bool $value): bool => !$value]; - yield [true, [true, true, true], fn (bool $value): bool => $value]; - yield [false, [true, true, true], fn (bool $value): bool => !$value]; - yield [false, [false, false, false], fn (bool $value): bool => $value]; - yield [true, [false, false, false], fn (bool $value): bool => !$value]; - yield [true, [false, false, false], fn (bool $value): bool => true]; - yield [false, [false, false, false], fn (bool $value): bool => false]; - yield [false, [1, 2, 3], fn (int $i): bool => $i > 3]; - yield [true, [4, 5, 6], fn (int $i): bool => $i > 3]; - yield [true, [1, 2, 3, 4, 5, 6], fn (int $i): bool => $i > 3]; - yield [false, [], fn (bool $value): bool => false]; + yield [true, [false, true, true], static fn (bool $value): bool => $value]; + yield [true, [false, true, true], static fn (bool $value): bool => !$value]; + yield [true, [true, true, true], static fn (bool $value): bool => $value]; + yield [false, [true, true, true], static fn (bool $value): bool => !$value]; + yield [false, [false, false, false], static fn (bool $value): bool => $value]; + yield [true, [false, false, false], static fn (bool $value): bool => !$value]; + yield [true, [false, false, false], static fn (bool $value): bool => true]; + yield [false, [false, false, false], static fn (bool $value): bool => false]; + yield [false, [1, 2, 3], static fn (int $i): bool => $i > 3]; + yield [true, [4, 5, 6], static fn (int $i): bool => $i > 3]; + yield [true, [1, 2, 3, 4, 5, 6], static fn (int $i): bool => $i > 3]; + yield [false, [], static fn (bool $value): bool => false]; } } diff --git a/tests/Psl/Iter/ApplyTest.php b/tests/Psl/Iter/ApplyTest.php index bf1abace..a0a7f739 100644 --- a/tests/Psl/Iter/ApplyTest.php +++ b/tests/Psl/Iter/ApplyTest.php @@ -8,13 +8,13 @@ use Psl\Collection\MutableVector; use Psl\Iter; -class ApplyTest extends TestCase +final class ApplyTest extends TestCase { public function testApply(): void { $vec = new MutableVector([]); - Iter\apply([1, 2, 3], fn (int $i) => $vec->add($i)); + Iter\apply([1, 2, 3], static fn (int $i) => $vec->add($i)); - self::assertSame([1, 2, 3], $vec->toArray()); + static::assertSame([1, 2, 3], $vec->toArray()); } } diff --git a/tests/Psl/Iter/ChainTest.php b/tests/Psl/Iter/ChainTest.php index caf3a920..4afc1ca1 100644 --- a/tests/Psl/Iter/ChainTest.php +++ b/tests/Psl/Iter/ChainTest.php @@ -8,7 +8,7 @@ use Psl\Collection; use Psl\Iter; -class ChainTest extends TestCase +final class ChainTest extends TestCase { public function testChain(): void { diff --git a/tests/Psl/Iter/ChunkTest.php b/tests/Psl/Iter/ChunkTest.php index 35d658b9..04815499 100644 --- a/tests/Psl/Iter/ChunkTest.php +++ b/tests/Psl/Iter/ChunkTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class ChunkTest extends TestCase +final class ChunkTest extends TestCase { /** * @psalm-template T @@ -21,7 +21,7 @@ public function testChunk(array $expected, iterable $iterable, int $size): void { $chunks = Iter\chunk($iterable, $size); - self::assertSame($expected, Iter\to_array($chunks)); + static::assertSame($expected, Iter\to_array($chunks)); } public function provideData(): iterable diff --git a/tests/Psl/Iter/ChunkWithKeysTest.php b/tests/Psl/Iter/ChunkWithKeysTest.php index 48da62bb..035381e7 100644 --- a/tests/Psl/Iter/ChunkWithKeysTest.php +++ b/tests/Psl/Iter/ChunkWithKeysTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class ChunkWithKeysTest extends TestCase +final class ChunkWithKeysTest extends TestCase { /** * @psalm-template Tk @@ -22,7 +22,7 @@ public function testChunkWithKeys(array $expected, iterable $iterable, int $size { $chunks = Iter\chunk_with_keys($iterable, $size); - self::assertSame($expected, Iter\to_array($chunks)); + static::assertSame($expected, Iter\to_array($chunks)); } public function provideData(): iterable diff --git a/tests/Psl/Iter/ContainsKeyTest.php b/tests/Psl/Iter/ContainsKeyTest.php index cced3679..b7987ade 100644 --- a/tests/Psl/Iter/ContainsKeyTest.php +++ b/tests/Psl/Iter/ContainsKeyTest.php @@ -8,7 +8,7 @@ use Psl\Collection; use Psl\Iter; -class ContainsKeyTest extends TestCase +final class ContainsKeyTest extends TestCase { /** * @psalm-template Tk @@ -21,7 +21,7 @@ class ContainsKeyTest extends TestCase */ public function testContainsKey(bool $expected, iterable $iterable, $key): void { - self::assertSame($expected, Iter\contains_key($iterable, $key)); + static::assertSame($expected, Iter\contains_key($iterable, $key)); } public function provideData(): iterable @@ -38,7 +38,7 @@ public function provideData(): iterable yield [true, new Collection\Vector([1, 2]), 0]; yield [true, new Collection\Vector([1, 2]), 1]; yield [false, new Collection\Vector([1, 2]), 2]; - yield [true, (fn () => yield 'foo' => 'bar')(), 'foo']; - yield [false, (fn () => yield 'foo' => 'bar')(), 'bar']; + yield [true, (static fn () => yield 'foo' => 'bar')(), 'foo']; + yield [false, (static fn () => yield 'foo' => 'bar')(), 'bar']; } } diff --git a/tests/Psl/Iter/ContainsTest.php b/tests/Psl/Iter/ContainsTest.php index f517a9fb..319abd8e 100644 --- a/tests/Psl/Iter/ContainsTest.php +++ b/tests/Psl/Iter/ContainsTest.php @@ -8,7 +8,7 @@ use Psl\Collection; use Psl\Iter; -class ContainsTest extends TestCase +final class ContainsTest extends TestCase { /** @@ -21,7 +21,7 @@ class ContainsTest extends TestCase */ public function testContainsKey(bool $expected, iterable $iterable, $value): void { - self::assertSame($expected, Iter\contains($iterable, $value)); + static::assertSame($expected, Iter\contains($iterable, $value)); } public function provideData(): iterable @@ -41,7 +41,7 @@ public function provideData(): iterable yield [false, new Collection\Vector([1, 2]), 0]; yield [true, new Collection\Vector([1, 2]), 1]; yield [true, new Collection\Vector([1, 2]), 2]; - yield [false, (fn () => yield 'foo' => 'bar')(), 'foo']; - yield [true, (fn () => yield 'foo' => 'bar')(), 'bar']; + yield [false, (static fn () => yield 'foo' => 'bar')(), 'foo']; + yield [true, (static fn () => yield 'foo' => 'bar')(), 'bar']; } } diff --git a/tests/Psl/Iter/CountTest.php b/tests/Psl/Iter/CountTest.php index 261cb34f..b448e191 100644 --- a/tests/Psl/Iter/CountTest.php +++ b/tests/Psl/Iter/CountTest.php @@ -8,14 +8,14 @@ use Psl\Collection; use Psl\Iter; -class CountTest extends TestCase +final class CountTest extends TestCase { /** * @dataProvider provideData */ public function testCount(int $expected, iterable $iterable): void { - self::assertSame($expected, Iter\count($iterable)); + static::assertSame($expected, Iter\count($iterable)); } public function provideData(): iterable @@ -24,7 +24,7 @@ public function provideData(): iterable yield [1, [null]]; yield [3, [1, 2, 3]]; yield [10, Iter\range(1, 10)]; - yield [1, (fn () => yield 1 => 2)()]; + yield [1, (static fn () => yield 1 => 2)()]; yield [21, new Collection\Vector(Iter\range(0, 100, 5))]; } } diff --git a/tests/Psl/Iter/DiffByKeyTest.php b/tests/Psl/Iter/DiffByKeyTest.php index e3edf68e..5fe9a492 100644 --- a/tests/Psl/Iter/DiffByKeyTest.php +++ b/tests/Psl/Iter/DiffByKeyTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class DiffByKeyTest extends TestCase +final class DiffByKeyTest extends TestCase { /** * @dataProvider provideData @@ -16,7 +16,7 @@ public function testDiffByKey(array $expected, iterable $first, iterable $second { $result = Iter\diff_by_key($first, $second, ...$rest); - self::assertSame($expected, Iter\to_array_with_keys($result)); + static::assertSame($expected, Iter\to_array_with_keys($result)); } public function provideData(): iterable diff --git a/tests/Psl/Iter/DropTest.php b/tests/Psl/Iter/DropTest.php index dfa86736..fbc96786 100644 --- a/tests/Psl/Iter/DropTest.php +++ b/tests/Psl/Iter/DropTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class DropTest extends TestCase +final class DropTest extends TestCase { /** * @dataProvider provideData @@ -16,7 +16,7 @@ public function testDrop(array $expected, iterable $iterable, int $n): void { $result = Iter\drop($iterable, $n); - self::assertSame($expected, Iter\to_array_with_keys($result)); + static::assertSame($expected, Iter\to_array_with_keys($result)); } public function provideData(): iterable diff --git a/tests/Psl/Iter/DropWhileTest.php b/tests/Psl/Iter/DropWhileTest.php index edb0389b..68aee0fd 100644 --- a/tests/Psl/Iter/DropWhileTest.php +++ b/tests/Psl/Iter/DropWhileTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class DropWhileTest extends TestCase +final class DropWhileTest extends TestCase { /** * @dataProvider provideData @@ -16,24 +16,24 @@ public function testDropWhile(array $expected, iterable $iterable, callable $cal { $result = Iter\drop_while($iterable, $callable); - self::assertSame($expected, Iter\to_array_with_keys($result)); + static::assertSame($expected, Iter\to_array_with_keys($result)); } public function provideData(): iterable { - yield [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], fn (int $_): bool => false]; - yield [[3 => 4, 4 => 5], [1, 2, 3, 4, 5], fn (int $i) => $i <= 3]; - yield [[2 => 3, 3 => 4, 4 => 5], [1, 2, 3, 4, 5], fn (int $i) => $i <= 2]; - yield [[], [1, 2, 3, 4, 5], fn (int $_) => true]; - - yield [[1, 2, 3, 4, 5], Iter\range(1, 5), fn (int $_): bool => false]; - yield [[3 => 4, 4 => 5], Iter\range(1, 5), fn (int $i) => $i <= 3]; - yield [[2 => 3, 3 => 4, 4 => 5], Iter\range(1, 5), fn (int $i) => $i <= 2]; - yield [[], Iter\range(1, 5), fn (int $_) => true]; - - yield [[1, 2, 3, 4, 5], Iter\range(1, 5), fn (int $_): bool => false]; - yield [[3 => 4, 4 => 5], Iter\range(1, 5), fn (int $i) => $i <= 3]; - yield [[2 => 3, 3 => 4, 4 => 5], Iter\range(1, 5), fn (int $i) => $i <= 2]; - yield [[], Iter\range(1, 5), fn (int $_) => true]; + yield [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], static fn (int $_): bool => false]; + yield [[3 => 4, 4 => 5], [1, 2, 3, 4, 5], static fn (int $i) => $i <= 3]; + yield [[2 => 3, 3 => 4, 4 => 5], [1, 2, 3, 4, 5], static fn (int $i) => $i <= 2]; + yield [[], [1, 2, 3, 4, 5], static fn (int $_) => true]; + + yield [[1, 2, 3, 4, 5], Iter\range(1, 5), static fn (int $_): bool => false]; + yield [[3 => 4, 4 => 5], Iter\range(1, 5), static fn (int $i) => $i <= 3]; + yield [[2 => 3, 3 => 4, 4 => 5], Iter\range(1, 5), static fn (int $i) => $i <= 2]; + yield [[], Iter\range(1, 5), static fn (int $_) => true]; + + yield [[1, 2, 3, 4, 5], Iter\range(1, 5), static fn (int $_): bool => false]; + yield [[3 => 4, 4 => 5], Iter\range(1, 5), static fn (int $i) => $i <= 3]; + yield [[2 => 3, 3 => 4, 4 => 5], Iter\range(1, 5), static fn (int $i) => $i <= 2]; + yield [[], Iter\range(1, 5), static fn (int $_) => true]; } } diff --git a/tests/Psl/Iter/EnumerateTest.php b/tests/Psl/Iter/EnumerateTest.php index b44ec65c..2707dd09 100644 --- a/tests/Psl/Iter/EnumerateTest.php +++ b/tests/Psl/Iter/EnumerateTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class EnumerateTest extends TestCase +final class EnumerateTest extends TestCase { /** * @dataProvider provideData @@ -16,7 +16,7 @@ public function testEnumerate(array $expected, iterable $iterable): void { $result = Iter\enumerate($iterable); - self::assertSame($expected, Iter\to_array_with_keys($result)); + static::assertSame($expected, Iter\to_array_with_keys($result)); } public function provideData(): iterable diff --git a/tests/Psl/Iter/FilterKeysTest.php b/tests/Psl/Iter/FilterKeysTest.php index 401685fc..7e939d20 100644 --- a/tests/Psl/Iter/FilterKeysTest.php +++ b/tests/Psl/Iter/FilterKeysTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class FilterKeysTest extends TestCase +final class FilterKeysTest extends TestCase { /** * @dataProvider provideData @@ -16,21 +16,21 @@ public function testFilterKeys(array $expected, iterable $iterable, ?callable $p { $result = Iter\filter_keys($iterable, $predicate); - self::assertSame($expected, Iter\to_array_with_keys($result)); + static::assertSame($expected, Iter\to_array_with_keys($result)); } public function provideData(): iterable { yield [[], []]; yield [[1 => 'b'], ['a', 'b']]; - yield [[], ['a', 'b'], fn () => false]; - yield [['a', 'b'], ['a', 'b'], fn (int $_): bool => true]; - yield [['a'], ['a', 'b'], fn (int $k): bool => 1 !== $k]; + yield [[], ['a', 'b'], static fn () => false]; + yield [['a', 'b'], ['a', 'b'], static fn (int $_): bool => true]; + yield [['a'], ['a', 'b'], static fn (int $k): bool => 1 !== $k]; yield [[1 => 'b'], Iter\Iterator::create(['a', 'b'])]; - yield [[], Iter\Iterator::create(['a', 'b']), fn () => false]; - yield [['a', 'b'], Iter\Iterator::create(['a', 'b']), fn (int $_): bool => true]; - yield [['a'], Iter\Iterator::create(['a', 'b']), fn (int $k): bool => 1 !== $k]; + yield [[], Iter\Iterator::create(['a', 'b']), static fn () => false]; + yield [['a', 'b'], Iter\Iterator::create(['a', 'b']), static fn (int $_): bool => true]; + yield [['a'], Iter\Iterator::create(['a', 'b']), static fn (int $k): bool => 1 !== $k]; yield [[1 => 'b'], (static function () { yield 'a'; @@ -39,14 +39,14 @@ public function provideData(): iterable yield [[], (static function () { yield 'a'; yield 'b'; - })(), fn () => false]; + })(), static fn () => false]; yield [['a', 'b'], (static function () { yield 'a'; yield 'b'; - })(), fn (int $_): bool => true]; + })(), static fn (int $_): bool => true]; yield [['a'], (static function () { yield 'a'; yield 'b'; - })(), fn (int $k): bool => 1 !== $k]; + })(), static fn (int $k): bool => 1 !== $k]; } } diff --git a/tests/Psl/Iter/FilterNullsTest.php b/tests/Psl/Iter/FilterNullsTest.php index 5a169bfe..5901a896 100644 --- a/tests/Psl/Iter/FilterNullsTest.php +++ b/tests/Psl/Iter/FilterNullsTest.php @@ -8,22 +8,22 @@ use Psl\Collection; use Psl\Iter; -class FilterNullsTest extends TestCase +final class FilterNullsTest extends TestCase { public function testFilterNulls(): void { - self::assertCount(0, Iter\filter_nulls([])); - self::assertCount(0, Iter\filter_nulls([null, null])); - self::assertCount(1, Iter\filter_nulls([null, false])); - self::assertCount(1, Iter\filter_nulls([null, 'null'])); - self::assertCount(1, Iter\filter_nulls(['null'])); - self::assertCount(1, Iter\filter_nulls(Iter\Iterator::create(['null']))); - self::assertCount(0, Iter\filter_nulls(Iter\Iterator::create([null]))); - self::assertCount(0, Iter\filter_nulls(Iter\Iterator::create([null, null]))); - self::assertCount(3, Iter\filter_nulls(Iter\Iterator::create([null, false, '', 0]))); - self::assertCount(3, Iter\filter_nulls(new Collection\Vector([null, false, '', 0]))); - self::assertCount(3, Iter\filter_nulls(new Collection\Map([null, false, '', 0]))); - self::assertCount(3, Iter\filter_nulls((static function (): iterable { + static::assertCount(0, Iter\filter_nulls([])); + static::assertCount(0, Iter\filter_nulls([null, null])); + static::assertCount(1, Iter\filter_nulls([null, false])); + static::assertCount(1, Iter\filter_nulls([null, 'null'])); + static::assertCount(1, Iter\filter_nulls(['null'])); + static::assertCount(1, Iter\filter_nulls(Iter\Iterator::create(['null']))); + static::assertCount(0, Iter\filter_nulls(Iter\Iterator::create([null]))); + static::assertCount(0, Iter\filter_nulls(Iter\Iterator::create([null, null]))); + static::assertCount(3, Iter\filter_nulls(Iter\Iterator::create([null, false, '', 0]))); + static::assertCount(3, Iter\filter_nulls(new Collection\Vector([null, false, '', 0]))); + static::assertCount(3, Iter\filter_nulls(new Collection\Map([null, false, '', 0]))); + static::assertCount(3, Iter\filter_nulls((static function (): iterable { yield null; yield false; yield ''; diff --git a/tests/Psl/Iter/FilterTest.php b/tests/Psl/Iter/FilterTest.php index ad9127b6..82517909 100644 --- a/tests/Psl/Iter/FilterTest.php +++ b/tests/Psl/Iter/FilterTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class FilterTest extends TestCase +final class FilterTest extends TestCase { /** * @dataProvider provideData @@ -16,21 +16,21 @@ public function testFilter(array $expected, iterable $iterable, ?callable $predi { $result = Iter\filter($iterable, $predicate); - self::assertSame($expected, Iter\to_array_with_keys($result)); + static::assertSame($expected, Iter\to_array_with_keys($result)); } public function provideData(): iterable { yield [[], []]; yield [['a', 'b'], ['a', 'b']]; - yield [[], ['a', 'b'], fn () => false]; - yield [['a', 'b'], ['a', 'b'], fn (string $_): bool => true]; - yield [['a'], ['a', 'b'], fn (string $v): bool => 'b' !== $v]; + yield [[], ['a', 'b'], static fn () => false]; + yield [['a', 'b'], ['a', 'b'], static fn (string $_): bool => true]; + yield [['a'], ['a', 'b'], static fn (string $v): bool => 'b' !== $v]; yield [['a', 'b'], Iter\Iterator::create(['a', 'b'])]; - yield [[], Iter\Iterator::create(['a', 'b']), fn () => false]; - yield [['a', 'b'], Iter\Iterator::create(['a', 'b']), fn (string $_): bool => true]; - yield [['a'], Iter\Iterator::create(['a', 'b']), fn (string $v): bool => 'b' !== $v]; + yield [[], Iter\Iterator::create(['a', 'b']), static fn () => false]; + yield [['a', 'b'], Iter\Iterator::create(['a', 'b']), static fn (string $_): bool => true]; + yield [['a'], Iter\Iterator::create(['a', 'b']), static fn (string $v): bool => 'b' !== $v]; yield [['a', 'b'], (static function () { yield 'a'; @@ -39,14 +39,14 @@ public function provideData(): iterable yield [[], (static function () { yield 'a'; yield 'b'; - })(), fn () => false]; + })(), static fn () => false]; yield [['a', 'b'], (static function () { yield 'a'; yield 'b'; - })(), fn (string $_): bool => true]; + })(), static fn (string $_): bool => true]; yield [['a'], (static function () { yield 'a'; yield 'b'; - })(), fn (string $v): bool => 'b' !== $v]; + })(), static fn (string $v): bool => 'b' !== $v]; } } diff --git a/tests/Psl/Iter/FilterWithKeyTest.php b/tests/Psl/Iter/FilterWithKeyTest.php index bdb7b825..255f8e60 100644 --- a/tests/Psl/Iter/FilterWithKeyTest.php +++ b/tests/Psl/Iter/FilterWithKeyTest.php @@ -4,11 +4,15 @@ namespace Psl\Tests\Iter; +use ArrayIterator; +use ArrayObject; use PHPUnit\Framework\TestCase; use Psl\Collection; use Psl\Iter; +use SplDoublyLinkedList; +use SplFixedArray; -class FilterWithKeyTest extends TestCase +final class FilterWithKeyTest extends TestCase { /** * @dataProvider provideData @@ -17,32 +21,40 @@ public function testFilterWithKey(array $expected, iterable $iterable, ?callable { $result = Iter\filter_with_key($iterable, $predicate); - self::assertSame($expected, Iter\to_array_with_keys($result)); + static::assertSame($expected, Iter\to_array_with_keys($result)); } public function provideData(): iterable { yield [[], []]; yield [['a', 'b'], ['a', 'b']]; - yield [[], ['a', 'b'], fn (int $_k, string $_v) => false]; - yield [['a', 'b'], ['a', 'b'], fn (int $_k, string $_v): bool => true]; - yield [['a'], ['a', 'b'], fn (int $k, string $v): bool => 'b' !== $v]; - yield [[], ['a', 'b'], fn (int $k, string $v): bool => 'b' !== $v && 0 !== $k]; - yield [['a'], ['a', 'b'], fn (int $k, string $v): bool => 'b' !== $v && 1 !== $k]; - yield [[], ['a', 'b'], fn (int $k, string $v): bool => 'a' !== $v && 1 !== $k]; - yield [[1 => 'b'], ['a', 'b'], fn (int $k, string $v): bool => 'a' !== $v && 0 !== $k]; - - yield [[], new \SplFixedArray(0)]; + yield [[], ['a', 'b'], static fn (int $_k, string $_v) => false]; + yield [['a', 'b'], ['a', 'b'], static fn (int $_k, string $_v): bool => true]; + yield [['a'], ['a', 'b'], static fn (int $k, string $v): bool => 'b' !== $v]; + yield [[], ['a', 'b'], static fn (int $k, string $v): bool => 'b' !== $v && 0 !== $k]; + yield [['a'], ['a', 'b'], static fn (int $k, string $v): bool => 'b' !== $v && 1 !== $k]; + yield [[], ['a', 'b'], static fn (int $k, string $v): bool => 'a' !== $v && 1 !== $k]; + yield [[1 => 'b'], ['a', 'b'], static fn (int $k, string $v): bool => 'a' !== $v && 0 !== $k]; + + yield [[], new SplFixedArray(0)]; yield [['a', 'b'], new Collection\Vector(['a', 'b'])]; - yield [[], new Collection\Map(['a', 'b']), fn (int $_k, string $_v) => false]; - yield [['a', 'b'], Iter\Iterator::create(['a', 'b']), fn (int $_k, string $_v): bool => true]; - yield [['a'], new Collection\MutableMap(['a', 'b']), fn (int $k, string $v): bool => 'b' !== $v]; - yield [[], new Collection\MutableVector(['a', 'b']), fn (int $k, string $v): bool => 'b' !== $v && 0 !== $k]; - yield [['a'], Iter\Iterator::create(['a', 'b']), fn (int $k, string $v): bool => 'b' !== $v && 1 !== $k]; - yield [[], new \ArrayIterator(['a', 'b']), fn (int $k, string $v): bool => 'a' !== $v && 1 !== $k]; - yield [[1 => 'b'], new \ArrayObject(['a', 'b']), fn (int $k, string $v): bool => 'a' !== $v && 0 !== $k]; - - $doublyLinkedList = new \SplDoublyLinkedList(); + yield [[], new Collection\Map(['a', 'b']), static fn (int $_k, string $_v) => false]; + yield [['a', 'b'], Iter\Iterator::create(['a', 'b']), static fn (int $_k, string $_v): bool => true]; + yield [['a'], new Collection\MutableMap(['a', 'b']), static fn (int $k, string $v): bool => 'b' !== $v]; + yield [ + [], + new Collection\MutableVector(['a', 'b']), + static fn (int $k, string $v): bool => 'b' !== $v && 0 !== $k + ]; + yield [ + ['a'], + Iter\Iterator::create(['a', 'b']), + static fn (int $k, string $v): bool => 'b' !== $v && 1 !== $k + ]; + yield [[], new ArrayIterator(['a', 'b']), static fn (int $k, string $v): bool => 'a' !== $v && 1 !== $k]; + yield [[1 => 'b'], new ArrayObject(['a', 'b']), static fn (int $k, string $v): bool => 'a' !== $v && 0 !== $k]; + + $doublyLinkedList = new SplDoublyLinkedList(); $doublyLinkedList->add(0, 'a'); $doublyLinkedList->add(1, 'b'); yield [['a', 'b'], $doublyLinkedList]; diff --git a/tests/Psl/Iter/FirstKeyTest.php b/tests/Psl/Iter/FirstKeyTest.php index 81310591..42e257f5 100644 --- a/tests/Psl/Iter/FirstKeyTest.php +++ b/tests/Psl/Iter/FirstKeyTest.php @@ -7,8 +7,9 @@ use PHPUnit\Framework\TestCase; use Psl\Collection; use Psl\Iter; +use SplDoublyLinkedList; -class FirstKeyTest extends TestCase +final class FirstKeyTest extends TestCase { /** * @dataProvider provideData @@ -17,13 +18,13 @@ public function testFirstKey($expected, iterable $iterable): void { $result = Iter\first_key($iterable); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideData(): iterable { yield [null, []]; - yield [null, new \SplDoublyLinkedList()]; + yield [null, new SplDoublyLinkedList()]; yield ['a', ['a' => 'b']]; yield [0, ['a', 'b']]; yield [0, new Collection\Vector(['a', 'b'])]; diff --git a/tests/Psl/Iter/FirstTest.php b/tests/Psl/Iter/FirstTest.php index 1f469112..a9892048 100644 --- a/tests/Psl/Iter/FirstTest.php +++ b/tests/Psl/Iter/FirstTest.php @@ -7,8 +7,9 @@ use PHPUnit\Framework\TestCase; use Psl\Collection; use Psl\Iter; +use SplDoublyLinkedList; -class FirstTest extends TestCase +final class FirstTest extends TestCase { /** * @dataProvider provideData @@ -17,13 +18,13 @@ public function testFirst($expected, iterable $iterable): void { $result = Iter\first($iterable); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideData(): iterable { yield [null, []]; - yield [null, new \SplDoublyLinkedList()]; + yield [null, new SplDoublyLinkedList()]; yield ['b', ['a' => 'b', 'c' => 'd']]; yield ['a', ['a', 'b']]; yield ['a', new Collection\Vector(['a', 'b'])]; diff --git a/tests/Psl/Iter/FlattenTest.php b/tests/Psl/Iter/FlattenTest.php index 22715ae1..ed8a42ac 100644 --- a/tests/Psl/Iter/FlattenTest.php +++ b/tests/Psl/Iter/FlattenTest.php @@ -8,14 +8,14 @@ use Psl\Collection; use Psl\Iter; -class FlattenTest extends TestCase +final class FlattenTest extends TestCase { public function testFlatten(): void { $result = Iter\flatten([ [1, 2, 3], new Collection\Map(['a' => 'b', 'c' => 'd', 'e' => 'f']), - (fn () => yield 'hey' => 'hello')() + (static fn () => yield 'hey' => 'hello')() ]); static::assertSame([ diff --git a/tests/Psl/Iter/FlipTest.php b/tests/Psl/Iter/FlipTest.php index b59a5c27..b18b4909 100644 --- a/tests/Psl/Iter/FlipTest.php +++ b/tests/Psl/Iter/FlipTest.php @@ -8,7 +8,7 @@ use Psl\Collection; use Psl\Iter; -class FlipTest extends TestCase +final class FlipTest extends TestCase { public function testFlip(): void { diff --git a/tests/Psl/Iter/FromEntriesTest.php b/tests/Psl/Iter/FromEntriesTest.php index e8b32987..2687f3d4 100644 --- a/tests/Psl/Iter/FromEntriesTest.php +++ b/tests/Psl/Iter/FromEntriesTest.php @@ -7,12 +7,12 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class FromEntriesTest extends TestCase +final class FromEntriesTest extends TestCase { public function testEmptyEntries(): void { $actual = Iter\from_entries([]); - self::assertCount(0, $actual); + static::assertCount(0, $actual); } public function testFromEntries(): void @@ -24,9 +24,9 @@ public function testFromEntries(): void $array = Iter\to_array_with_keys($actual); - self::assertCount(2, $array); - self::assertSame('hello', $array[1]); - self::assertSame('world', $array[2]); + static::assertCount(2, $array); + static::assertSame('hello', $array[1]); + static::assertSame('world', $array[2]); } public function testFromEntriesWithNonArrayKeyKeys(): void @@ -36,10 +36,10 @@ public function testFromEntriesWithNonArrayKeyKeys(): void [['3', '4'], 'world'] ]); - self::assertSame('hello', Iter\first($actual)); - self::assertSame('world', Iter\last($actual)); + static::assertSame('hello', Iter\first($actual)); + static::assertSame('world', Iter\last($actual)); - self::assertSame(['1', '2'], Iter\first_key($actual)); - self::assertSame(['3', '4'], Iter\last_key($actual)); + static::assertSame(['1', '2'], Iter\first_key($actual)); + static::assertSame(['3', '4'], Iter\last_key($actual)); } } diff --git a/tests/Psl/Iter/FromKeysTest.php b/tests/Psl/Iter/FromKeysTest.php index f2249c97..79bb4533 100644 --- a/tests/Psl/Iter/FromKeysTest.php +++ b/tests/Psl/Iter/FromKeysTest.php @@ -7,16 +7,16 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class FromKeysTest extends TestCase +final class FromKeysTest extends TestCase { public function testFromKeys(): void { - $actual = Iter\from_keys(['hello', 'world'], fn (string $_key) => false); + $actual = Iter\from_keys(['hello', 'world'], static fn (string $_key) => false); - self::assertSame('hello', Iter\first_key($actual)); - self::assertSame('world', Iter\last_key($actual)); - self::assertFalse(Iter\first($actual)); - self::assertFalse(Iter\last($actual)); + static::assertSame('hello', Iter\first_key($actual)); + static::assertSame('world', Iter\last_key($actual)); + static::assertFalse(Iter\first($actual)); + static::assertFalse(Iter\last($actual)); } public function testFromKeysWithNonArrayKeyKeys(): void @@ -24,11 +24,11 @@ public function testFromKeysWithNonArrayKeyKeys(): void $actual = Iter\from_keys([ [1, 'hello'], [2, 'world'] - ], fn (array $k) => $k[1]); + ], static fn (array $k) => $k[1]); - self::assertSame([1, 'hello'], Iter\first_key($actual)); - self::assertSame([2, 'world'], Iter\last_key($actual)); - self::assertSame('hello', Iter\first($actual)); - self::assertSame('world', Iter\last($actual)); + static::assertSame([1, 'hello'], Iter\first_key($actual)); + static::assertSame([2, 'world'], Iter\last_key($actual)); + static::assertSame('hello', Iter\first($actual)); + static::assertSame('world', Iter\last($actual)); } } diff --git a/tests/Psl/Iter/IsEmptyTest.php b/tests/Psl/Iter/IsEmptyTest.php index 084d1f43..743aa939 100644 --- a/tests/Psl/Iter/IsEmptyTest.php +++ b/tests/Psl/Iter/IsEmptyTest.php @@ -7,21 +7,21 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class IsEmptyTest extends TestCase +final class IsEmptyTest extends TestCase { /** * @dataProvider provideData */ public function testIsEmpty(bool $expected, iterable $iterable): void { - self::assertSame($expected, Iter\is_empty($iterable)); + static::assertSame($expected, Iter\is_empty($iterable)); } public function provideData(): iterable { yield [true, []]; yield [true, Iter\from_entries([])]; - yield [true, (fn () => yield from [])()]; + yield [true, (static fn () => yield from [])()]; yield [false, [null]]; yield [false, [false]]; diff --git a/tests/Psl/Iter/IteratorTest.php b/tests/Psl/Iter/IteratorTest.php index ffaa4be9..1481ee56 100644 --- a/tests/Psl/Iter/IteratorTest.php +++ b/tests/Psl/Iter/IteratorTest.php @@ -20,40 +20,40 @@ public function testCreateFromGenerator(): void public function testCreateFromFactory(): void { - $iterator = Iter\Iterator::from((fn () => yield from [1, 2, 3])); + $iterator = Iter\Iterator::from((static fn () => yield from [1, 2, 3])); static::assertCount(3, $iterator); } public function testSeek(): void { - $iterator = new Iter\Iterator((fn () => yield from [1, 2, 3, 4, 5])()); + $iterator = new Iter\Iterator((static fn () => yield from [1, 2, 3, 4, 5])()); - self::assertSame(1, $iterator->current()); + static::assertSame(1, $iterator->current()); $iterator->next(); - self::assertSame(2, $iterator->current()); + static::assertSame(2, $iterator->current()); $iterator->next(); $iterator->seek(0); - self::assertSame(1, $iterator->current()); + static::assertSame(1, $iterator->current()); $iterator->seek(4); - self::assertSame(5, $iterator->current()); + static::assertSame(5, $iterator->current()); - self::assertSame(5, $iterator->count()); + static::assertSame(5, $iterator->count()); $iterator->seek(1); - self::assertSame(2, $iterator->current()); + static::assertSame(2, $iterator->current()); $iterator->seek(4); - self::assertSame(5, $iterator->current()); + static::assertSame(5, $iterator->current()); - self::assertSame(5, $iterator->count()); + static::assertSame(5, $iterator->count()); } public function testSeekThrowsForOutOfBoundIndex(): void { - $iterator = new Iter\Iterator((fn () => yield from [1, 2, 3, 4, 5])()); + $iterator = new Iter\Iterator((static fn () => yield from [1, 2, 3, 4, 5])()); $this->expectException(InvariantViolationException::class); $this->expectExceptionMessage('Position is out-of-bounds.'); @@ -81,7 +81,7 @@ public function testIterating(): void /** * Assert supports non-array-key keys. ( in this case, keys are arrays ) */ - self::assertSame(['foo', 'bar'], $k); + static::assertSame(['foo', 'bar'], $k); } } @@ -97,7 +97,7 @@ public function testIterating(): void * - The iterator is capable of rewinding a generator. * - The generator is not exhausted immediately on construction. */ - self::assertSame([ + static::assertSame([ 'generator (0)', 'foreach (0)', 'generator (1)', @@ -148,7 +148,7 @@ public function testRewindingValidGenerator(): void $spy->add('for (' . $rewindable->current() . ')'); } - self::assertSame([ + static::assertSame([ 'generator (0)', 'foreach (0)', 'do while (0)', diff --git a/tests/Psl/Iter/KeysTest.php b/tests/Psl/Iter/KeysTest.php index 15e7e0df..4be1d9c8 100644 --- a/tests/Psl/Iter/KeysTest.php +++ b/tests/Psl/Iter/KeysTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class KeysTest extends TestCase +final class KeysTest extends TestCase { /** * @dataProvider provideData @@ -16,7 +16,7 @@ public function testKeys(array $expected, iterable $iterable): void { $result = Iter\keys($iterable); - self::assertSame($expected, Iter\to_array_with_keys($result)); + static::assertSame($expected, Iter\to_array_with_keys($result)); } public function provideData(): iterable diff --git a/tests/Psl/Iter/LastKeyTest.php b/tests/Psl/Iter/LastKeyTest.php index 870fe651..7d475ce7 100644 --- a/tests/Psl/Iter/LastKeyTest.php +++ b/tests/Psl/Iter/LastKeyTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class LastKeyTest extends TestCase +final class LastKeyTest extends TestCase { /** * @dataProvider provideData @@ -16,7 +16,7 @@ public function testLastKey($expected, iterable $iterable): void { $result = Iter\last_key($iterable); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideData(): iterable @@ -28,6 +28,6 @@ public function provideData(): iterable yield [null, []]; yield [0, [null]]; yield [1, [null, null]]; - yield [[1, 2], (fn () => yield [1, 2] => 'hello')()]; + yield [[1, 2], (static fn () => yield [1, 2] => 'hello')()]; } } diff --git a/tests/Psl/Iter/LastTest.php b/tests/Psl/Iter/LastTest.php index ab978767..9e086d78 100644 --- a/tests/Psl/Iter/LastTest.php +++ b/tests/Psl/Iter/LastTest.php @@ -7,8 +7,9 @@ use PHPUnit\Framework\TestCase; use Psl\Collection; use Psl\Iter; +use SplDoublyLinkedList; -class LastTest extends TestCase +final class LastTest extends TestCase { /** * @dataProvider provideData @@ -17,13 +18,13 @@ public function testLast($expected, iterable $iterable): void { $result = Iter\last($iterable); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideData(): iterable { yield [null, []]; - yield [null, new \SplDoublyLinkedList()]; + yield [null, new SplDoublyLinkedList()]; yield ['d', ['a' => 'b', 'c' => 'd']]; yield ['b', ['a', 'b']]; yield ['b', new Collection\Vector(['a', 'b'])]; diff --git a/tests/Psl/Iter/MapKeysTest.php b/tests/Psl/Iter/MapKeysTest.php index d17049bc..d24b3866 100644 --- a/tests/Psl/Iter/MapKeysTest.php +++ b/tests/Psl/Iter/MapKeysTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class MapKeysTest extends TestCase +final class MapKeysTest extends TestCase { /** * @dataProvider provideData @@ -16,16 +16,16 @@ public function testMapKeys(array $expected, iterable $iterable, callable $funct { $result = Iter\map_keys($iterable, $function); - self::assertSame($expected, Iter\to_array_with_keys($result)); + static::assertSame($expected, Iter\to_array_with_keys($result)); } public function provideData(): iterable { - yield [[1, 2, 3], [1, 2, 3], fn (int $k): int => $k]; - yield [[1, 2 => 2, 4 => 3], [1, 2, 3], fn (int $k): int => $k * 2]; - yield [['0' => 1, '1' => 2, '2' => 3], [1, 2, 3], fn (int $k): string => (string) $k]; - yield [[], [], fn (int $k): string => (string) $k]; - yield [[], Iter\Iterator::create([]), fn (int $k): string => (string) $k]; - yield [['0' => 1, '1' => 2], Iter\Iterator::create([1, 2]), fn (int $k): string => (string) $k]; + yield [[1, 2, 3], [1, 2, 3], static fn (int $k): int => $k]; + yield [[1, 2 => 2, 4 => 3], [1, 2, 3], static fn (int $k): int => $k * 2]; + yield [['0' => 1, '1' => 2, '2' => 3], [1, 2, 3], static fn (int $k): string => (string) $k]; + yield [[], [], static fn (int $k): string => (string) $k]; + yield [[], Iter\Iterator::create([]), static fn (int $k): string => (string) $k]; + yield [['0' => 1, '1' => 2], Iter\Iterator::create([1, 2]), static fn (int $k): string => (string) $k]; } } diff --git a/tests/Psl/Iter/MapTest.php b/tests/Psl/Iter/MapTest.php index bf37c5f2..58b32a7e 100644 --- a/tests/Psl/Iter/MapTest.php +++ b/tests/Psl/Iter/MapTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class MapTest extends TestCase +final class MapTest extends TestCase { /** * @dataProvider provideData @@ -16,16 +16,16 @@ public function testMap(array $expected, iterable $iterable, callable $function) { $result = Iter\map($iterable, $function); - self::assertSame($expected, Iter\to_array_with_keys($result)); + static::assertSame($expected, Iter\to_array_with_keys($result)); } public function provideData(): iterable { - yield [[1, 2, 3], [1, 2, 3], fn (int $v): int => $v]; - yield [[2, 4, 6], [1, 2, 3], fn (int $v): int => $v * 2]; - yield [['1', '2', '3'], [1, 2, 3], fn (int $v): string => (string) $v]; - yield [[], [], fn (int $k): string => (string) $v]; - yield [[], Iter\Iterator::create([]), fn (int $v): string => (string) $v]; - yield [['1', '2'], Iter\Iterator::create([1, 2]), fn (int $v): string => (string) $v]; + yield [[1, 2, 3], [1, 2, 3], static fn (int $v): int => $v]; + yield [[2, 4, 6], [1, 2, 3], static fn (int $v): int => $v * 2]; + yield [['1', '2', '3'], [1, 2, 3], static fn (int $v): string => (string) $v]; + yield [[], [], static fn (int $k): string => (string) $v]; + yield [[], Iter\Iterator::create([]), static fn (int $v): string => (string) $v]; + yield [['1', '2'], Iter\Iterator::create([1, 2]), static fn (int $v): string => (string) $v]; } } diff --git a/tests/Psl/Iter/MapWithKeyTest.php b/tests/Psl/Iter/MapWithKeyTest.php index a961820c..261c1d0c 100644 --- a/tests/Psl/Iter/MapWithKeyTest.php +++ b/tests/Psl/Iter/MapWithKeyTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class MapWithKeyTest extends TestCase +final class MapWithKeyTest extends TestCase { /** * @dataProvider provideData @@ -16,16 +16,16 @@ public function testMapWithKey(array $expected, iterable $iterable, callable $fu { $result = Iter\map_with_key($iterable, $function); - self::assertSame($expected, Iter\to_array_with_keys($result)); + static::assertSame($expected, Iter\to_array_with_keys($result)); } public function provideData(): iterable { - yield [[1, 3, 5], [1, 2, 3], fn (int $k, int $v): int => $k + $v]; - yield [[0, 4, 16], [1, 2, 3], fn (int $k, int $v): int => $k * (2 ** $v)]; - yield [['1', '3', '5'], [1, 2, 3], fn (int $k, int $v): string => (string) ($k + $v)]; - yield [[], [], fn (int $k, int $v): string => (string) ($k + $v)]; - yield [[], Iter\Iterator::create([]), fn (int $k, int $v): string => (string) ($k + $v)]; - yield [['1', '3'], Iter\Iterator::create([1, 2]), fn (int $k, int $v): string => (string) ($k + $v)]; + yield [[1, 3, 5], [1, 2, 3], static fn (int $k, int $v): int => $k + $v]; + yield [[0, 4, 16], [1, 2, 3], static fn (int $k, int $v): int => $k * (2 ** $v)]; + yield [['1', '3', '5'], [1, 2, 3], static fn (int $k, int $v): string => (string) ($k + $v)]; + yield [[], [], static fn (int $k, int $v): string => (string) ($k + $v)]; + yield [[], Iter\Iterator::create([]), static fn (int $k, int $v): string => (string) ($k + $v)]; + yield [['1', '3'], Iter\Iterator::create([1, 2]), static fn (int $k, int $v): string => (string) ($k + $v)]; } } diff --git a/tests/Psl/Iter/MergeTest.php b/tests/Psl/Iter/MergeTest.php index a121ac7d..181027aa 100644 --- a/tests/Psl/Iter/MergeTest.php +++ b/tests/Psl/Iter/MergeTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class MergeTest extends TestCase +final class MergeTest extends TestCase { public function testMap(): void { diff --git a/tests/Psl/Iter/ProductTest.php b/tests/Psl/Iter/ProductTest.php index 9a63bee4..7345b38c 100644 --- a/tests/Psl/Iter/ProductTest.php +++ b/tests/Psl/Iter/ProductTest.php @@ -7,19 +7,19 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class ProductTest extends TestCase +final class ProductTest extends TestCase { public function testProduct(): void { $result = Iter\product(Iter\range(1, 2), Iter\range(3, 4)); $entries = Iter\to_array(Iter\enumerate($result)); - self::assertCount(4, $entries); + static::assertCount(4, $entries); - self::assertSame($entries[0], [[0, 0], [1, 3]]); - self::assertSame($entries[1], [[0, 1], [1, 4]]); - self::assertSame($entries[2], [[1, 0], [2, 3]]); - self::assertSame($entries[3], [[1, 1], [2, 4]]); + static::assertSame($entries[0], [[0, 0], [1, 3]]); + static::assertSame($entries[1], [[0, 1], [1, 4]]); + static::assertSame($entries[2], [[1, 0], [2, 3]]); + static::assertSame($entries[3], [[1, 1], [2, 4]]); } public function testProductEmpty(): void @@ -27,8 +27,8 @@ public function testProductEmpty(): void $result = Iter\product(...[]); $entries = Iter\to_array(Iter\enumerate($result)); - self::assertCount(1, $entries); + static::assertCount(1, $entries); - self::assertSame($entries[0], [[], []]); + static::assertSame($entries[0], [[], []]); } } diff --git a/tests/Psl/Iter/PullTest.php b/tests/Psl/Iter/PullTest.php index 405dc672..f4091ecd 100644 --- a/tests/Psl/Iter/PullTest.php +++ b/tests/Psl/Iter/PullTest.php @@ -8,17 +8,17 @@ use Psl\Iter; use Psl\Str; -class PullTest extends TestCase +final class PullTest extends TestCase { public function testPull(): void { $result = Iter\pull( Iter\range(0, 10), - fn ($i) => Str\chr($i + 65), - fn ($i) => 2 ** $i + static fn ($i) => Str\chr($i + 65), + static fn ($i) => 2 ** $i ); - self::assertSame([ + static::assertSame([ 1 => 'A', 2 => 'B', 4 => 'C', 8 => 'D', 16 => 'E', 32 => 'F', 64 => 'G', 128 => 'H', 256 => 'I', 512 => 'J', 1024 => 'K' ], Iter\to_array_with_keys($result)); diff --git a/tests/Psl/Iter/PullWithKeyTest.php b/tests/Psl/Iter/PullWithKeyTest.php index bd50f0d6..c185e1b5 100644 --- a/tests/Psl/Iter/PullWithKeyTest.php +++ b/tests/Psl/Iter/PullWithKeyTest.php @@ -8,17 +8,17 @@ use Psl\Iter; use Psl\Str; -class PullWithKeyTest extends TestCase +final class PullWithKeyTest extends TestCase { public function testPull(): void { $result = Iter\pull_with_key( Iter\range(0, 10), - fn ($k, $v) => Str\chr($v + $k + 65), - fn ($k, $v) => 2 ** ($v + $k) + static fn ($k, $v) => Str\chr($v + $k + 65), + static fn ($k, $v) => 2 ** ($v + $k) ); - self::assertSame([ + static::assertSame([ 1 => 'A', 4 => 'C', 16 => 'E', 64 => 'G', 256 => 'I', 1024 => 'K', 4096 => 'M', 16384 => 'O', 65536 => 'Q', 262144 => 'S', 1048576 => 'U' ], Iter\to_array_with_keys($result)); diff --git a/tests/Psl/Iter/RandomTest.php b/tests/Psl/Iter/RandomTest.php index 8930b337..29406c55 100644 --- a/tests/Psl/Iter/RandomTest.php +++ b/tests/Psl/Iter/RandomTest.php @@ -8,19 +8,19 @@ use Psl; use Psl\Iter; -class RandomTest extends TestCase +final class RandomTest extends TestCase { public function testRandom(): void { $iterable = [1, 2, 3, 4, 5]; $value = Iter\random($iterable); - self::assertTrue(Iter\contains($iterable, $value)); + static::assertTrue(Iter\contains($iterable, $value)); $iterable = Iter\to_iterator([1, 2, 3, 4, 5]); $value = Iter\random($iterable); - self::assertTrue(Iter\contains($iterable, $value)); + static::assertTrue(Iter\contains($iterable, $value)); } public function testRandomWithEmptyIterator(): void diff --git a/tests/Psl/Iter/RangeTest.php b/tests/Psl/Iter/RangeTest.php index 7247c763..44aa1186 100644 --- a/tests/Psl/Iter/RangeTest.php +++ b/tests/Psl/Iter/RangeTest.php @@ -8,15 +8,15 @@ use Psl; use Psl\Iter; -class RangeTest extends TestCase +final class RangeTest extends TestCase { public function testRange(): void { - self::assertSame([1], Iter\to_array(Iter\range(1, 1, 1))); - self::assertSame([0, 1, 2, 3, 4, 5], Iter\to_array(Iter\range(0, 5))); - self::assertSame([5, 4, 3, 2, 1, 0], Iter\to_array(Iter\range(5, 0))); - self::assertSame([0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0], Iter\to_array(Iter\range(0.0, 3.0, 0.5))); - self::assertSame([3.0, 2.5, 2.0, 1.5, 1.0, 0.5, 0.0], Iter\to_array(Iter\range(3.0, 0.0, -0.5))); + static::assertSame([1], Iter\to_array(Iter\range(1, 1, 1))); + static::assertSame([0, 1, 2, 3, 4, 5], Iter\to_array(Iter\range(0, 5))); + static::assertSame([5, 4, 3, 2, 1, 0], Iter\to_array(Iter\range(5, 0))); + static::assertSame([0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0], Iter\to_array(Iter\range(0.0, 3.0, 0.5))); + static::assertSame([3.0, 2.5, 2.0, 1.5, 1.0, 0.5, 0.0], Iter\to_array(Iter\range(3.0, 0.0, -0.5))); } public function testRandomThrowsIfEndIsGreaterThanStartAndStepIsNegative(): void diff --git a/tests/Psl/Iter/ReduceKeysTest.php b/tests/Psl/Iter/ReduceKeysTest.php index ba8876ce..82c32296 100644 --- a/tests/Psl/Iter/ReduceKeysTest.php +++ b/tests/Psl/Iter/ReduceKeysTest.php @@ -14,13 +14,13 @@ final class ReduceKeysTest extends TestCase */ public function testReduceKeys($expected, iterable $iterable, callable $function, $initial = null): void { - self::assertSame($expected, Iter\reduce_keys($iterable, $function, $initial)); + static::assertSame($expected, Iter\reduce_keys($iterable, $function, $initial)); } public function provideData(): iterable { - yield [null, [], fn ($accumulator, $k) => $accumulator, null]; - yield [3, [1, 2, 3], fn ($accumulator, $k) => $accumulator + $k, 0]; - yield [3, Iter\to_iterator([1, 2, 3]), fn ($accumulator, $k) => $accumulator + $k, 0]; + yield [null, [], static fn ($accumulator, $k) => $accumulator, null]; + yield [3, [1, 2, 3], static fn ($accumulator, $k) => $accumulator + $k, 0]; + yield [3, Iter\to_iterator([1, 2, 3]), static fn ($accumulator, $k) => $accumulator + $k, 0]; } } diff --git a/tests/Psl/Iter/ReduceTest.php b/tests/Psl/Iter/ReduceTest.php index 7798c330..84efd26e 100644 --- a/tests/Psl/Iter/ReduceTest.php +++ b/tests/Psl/Iter/ReduceTest.php @@ -7,20 +7,20 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class ReduceTest extends TestCase +final class ReduceTest extends TestCase { /** * @dataProvider provideData */ public function testReduce($expected, iterable $iterable, callable $function, $initial = null): void { - self::assertSame($expected, Iter\reduce($iterable, $function, $initial)); + static::assertSame($expected, Iter\reduce($iterable, $function, $initial)); } public function provideData(): iterable { - yield [null, [], fn ($accumulator, $v) => $accumulator, null]; - yield [6, [1, 2, 3], fn ($accumulator, $v) => $accumulator + $v, 0]; - yield [6, Iter\to_iterator([1, 2, 3]), fn ($accumulator, $v) => $accumulator + $v, 0]; + yield [null, [], static fn ($accumulator, $v) => $accumulator, null]; + yield [6, [1, 2, 3], static fn ($accumulator, $v) => $accumulator + $v, 0]; + yield [6, Iter\to_iterator([1, 2, 3]), static fn ($accumulator, $v) => $accumulator + $v, 0]; } } diff --git a/tests/Psl/Iter/ReduceWithKeysTest.php b/tests/Psl/Iter/ReduceWithKeysTest.php index 52bfccf8..98b58be3 100644 --- a/tests/Psl/Iter/ReduceWithKeysTest.php +++ b/tests/Psl/Iter/ReduceWithKeysTest.php @@ -7,20 +7,20 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class ReduceWithKeysTest extends TestCase +final class ReduceWithKeysTest extends TestCase { /** * @dataProvider provideData */ public function testReduceWithKeys($expected, iterable $iterable, callable $function, $initial = null): void { - self::assertSame($expected, Iter\reduce_with_keys($iterable, $function, $initial)); + static::assertSame($expected, Iter\reduce_with_keys($iterable, $function, $initial)); } public function provideData(): iterable { - yield [null, [], fn ($accumulator, $k, $v) => $accumulator, null]; - yield [6, [1, 2, 3], fn ($accumulator, $k, $v) => $accumulator + $v, 0]; - yield [6, Iter\to_iterator([1, 2, 3]), fn ($accumulator, $k, $v) => $accumulator + $v, 0]; + yield [null, [], static fn ($accumulator, $k, $v) => $accumulator, null]; + yield [6, [1, 2, 3], static fn ($accumulator, $k, $v) => $accumulator + $v, 0]; + yield [6, Iter\to_iterator([1, 2, 3]), static fn ($accumulator, $k, $v) => $accumulator + $v, 0]; } } diff --git a/tests/Psl/Iter/ReductionsTest.php b/tests/Psl/Iter/ReductionsTest.php index 1bd872e3..01e7844d 100644 --- a/tests/Psl/Iter/ReductionsTest.php +++ b/tests/Psl/Iter/ReductionsTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class ReductionsTest extends TestCase +final class ReductionsTest extends TestCase { /** * @dataProvider provideData @@ -16,13 +16,13 @@ public function testReductions(array $expected, iterable $iterable, callable $fu { $result = Iter\reductions($iterable, $function, $initial); - self::assertSame($expected, Iter\to_array_with_keys($result)); + static::assertSame($expected, Iter\to_array_with_keys($result)); } public function provideData(): iterable { - yield [[], [], fn ($accumulator, $k, $v) => $accumulator, null]; - yield [[1, 3, 6], [1, 2, 3], fn ($accumulator, $k, $v) => $accumulator + $v, 0]; - yield [[1, 3, 6], Iter\to_iterator([1, 2, 3]), fn ($accumulator, $k, $v) => $accumulator + $v, 0]; + yield [[], [], static fn ($accumulator, $k, $v) => $accumulator, null]; + yield [[1, 3, 6], [1, 2, 3], static fn ($accumulator, $k, $v) => $accumulator + $v, 0]; + yield [[1, 3, 6], Iter\to_iterator([1, 2, 3]), static fn ($accumulator, $k, $v) => $accumulator + $v, 0]; } } diff --git a/tests/Psl/Iter/ReindexTest.php b/tests/Psl/Iter/ReindexTest.php index 1b17c3ba..981f6259 100644 --- a/tests/Psl/Iter/ReindexTest.php +++ b/tests/Psl/Iter/ReindexTest.php @@ -7,12 +7,12 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class ReindexTest extends TestCase +final class ReindexTest extends TestCase { public function testReindex(): void { - $result = Iter\reindex([1, 2, 3], fn (int $value): int => $value); + $result = Iter\reindex([1, 2, 3], static fn (int $value): int => $value); - self::assertSame([1 => 1, 2 => 2, 3 => 3], Iter\to_array_with_keys($result)); + static::assertSame([1 => 1, 2 => 2, 3 => 3], Iter\to_array_with_keys($result)); } } diff --git a/tests/Psl/Iter/RepeatTest.php b/tests/Psl/Iter/RepeatTest.php index c908f434..ef930cfa 100644 --- a/tests/Psl/Iter/RepeatTest.php +++ b/tests/Psl/Iter/RepeatTest.php @@ -9,13 +9,13 @@ use Psl\Iter; use Psl\Math; -class RepeatTest extends TestCase +final class RepeatTest extends TestCase { public function testRepeat(): void { $result = Iter\repeat(42, 5); - self::assertSame([42, 42, 42, 42, 42], Iter\to_array($result)); + static::assertSame([42, 42, 42, 42, 42], Iter\to_array($result)); } public function testRepeatThrowsIfNumIsNegative(): void @@ -31,8 +31,8 @@ public function testRepeatToInfinityIfNumIsNotProvided(): void $result = Iter\repeat('hello'); $result->seek((int) Math\INFINITY); - self::assertTrue($result->valid()); - self::assertSame('hello', $result->current()); - self::assertSame((int) Math\INFINITY, $result->key()); + static::assertTrue($result->valid()); + static::assertSame('hello', $result->current()); + static::assertSame((int) Math\INFINITY, $result->key()); } } diff --git a/tests/Psl/Iter/ReproduceTest.php b/tests/Psl/Iter/ReproduceTest.php index 17fcdb8e..82d35783 100644 --- a/tests/Psl/Iter/ReproduceTest.php +++ b/tests/Psl/Iter/ReproduceTest.php @@ -14,8 +14,8 @@ final class ReproduceTest extends TestCase { public function testReproduce(): void { - self::assertSame([1], Iter\to_array((Iter\reproduce(Fun\identity(), 1)))); - self::assertSame([1, 2, 3], Iter\to_array(Iter\reproduce(Fun\identity(), 3))); + static::assertSame([1], Iter\to_array((Iter\reproduce(Fun\identity(), 1)))); + static::assertSame([1, 2, 3], Iter\to_array(Iter\reproduce(Fun\identity(), 3))); } public function testThrowsIfNumberIsLowerThan1(): void @@ -31,8 +31,8 @@ public function testReproduceToInfinityIfNumIsNotProvided(): void $result = Iter\reproduce(static fn () => 'hello'); $result->seek((int) Math\INFINITY); - self::assertTrue($result->valid()); - self::assertSame('hello', $result->current()); - self::assertSame((int) Math\INFINITY, $result->key()); + static::assertTrue($result->valid()); + static::assertSame('hello', $result->current()); + static::assertSame((int) Math\INFINITY, $result->key()); } } diff --git a/tests/Psl/Iter/ReverseTest.php b/tests/Psl/Iter/ReverseTest.php index a6278ef2..8c9c770f 100644 --- a/tests/Psl/Iter/ReverseTest.php +++ b/tests/Psl/Iter/ReverseTest.php @@ -7,19 +7,19 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class ReverseTest extends TestCase +final class ReverseTest extends TestCase { public function testReverse(): void { $result = Iter\reverse(['foo', 'bar', 'baz', 'qux']); - self::assertSame(['qux', 'baz', 'bar', 'foo'], Iter\to_array_with_keys($result)); + static::assertSame(['qux', 'baz', 'bar', 'foo'], Iter\to_array_with_keys($result)); } public function testReverseEarlyReturnForEmptyIterables(): void { $result = Iter\reverse(Iter\to_iterator([])); - self::assertSame([], Iter\to_array($result)); + static::assertSame([], Iter\to_array($result)); } } diff --git a/tests/Psl/Iter/SearchTest.php b/tests/Psl/Iter/SearchTest.php index 881776ff..81fffb9b 100644 --- a/tests/Psl/Iter/SearchTest.php +++ b/tests/Psl/Iter/SearchTest.php @@ -7,24 +7,24 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class SearchTest extends TestCase +final class SearchTest extends TestCase { /** * @dataProvider provideData */ public function testSearch($expected, iterable $iterable, callable $predicate): void { - self::assertSame($expected, Iter\search($iterable, $predicate)); + static::assertSame($expected, Iter\search($iterable, $predicate)); } public function provideData(): iterable { - yield ['baz', ['foo', 'bar', 'baz'], fn (string $v): bool => 'baz' === $v]; - yield [null, ['foo', 'bar', 'baz'], fn (string $v): bool => 'qux' === $v]; - yield [null, [], fn (string $v): bool => 'qux' === $v]; + yield ['baz', ['foo', 'bar', 'baz'], static fn (string $v): bool => 'baz' === $v]; + yield [null, ['foo', 'bar', 'baz'], static fn (string $v): bool => 'qux' === $v]; + yield [null, [], static fn (string $v): bool => 'qux' === $v]; - yield ['baz', Iter\to_iterator(['foo', 'bar', 'baz']), fn (string $v): bool => 'baz' === $v]; - yield [null, Iter\to_iterator(['foo', 'bar', 'baz']), fn (string $v): bool => 'qux' === $v]; - yield [null, Iter\to_iterator([]), fn (string $v): bool => 'qux' === $v]; + yield ['baz', Iter\to_iterator(['foo', 'bar', 'baz']), static fn (string $v): bool => 'baz' === $v]; + yield [null, Iter\to_iterator(['foo', 'bar', 'baz']), static fn (string $v): bool => 'qux' === $v]; + yield [null, Iter\to_iterator([]), static fn (string $v): bool => 'qux' === $v]; } } diff --git a/tests/Psl/Iter/SliceTest.php b/tests/Psl/Iter/SliceTest.php index d86d9896..ae81f347 100644 --- a/tests/Psl/Iter/SliceTest.php +++ b/tests/Psl/Iter/SliceTest.php @@ -8,27 +8,27 @@ use Psl; use Psl\Iter; -class SliceTest extends TestCase +final class SliceTest extends TestCase { public function testSlice(): void { $result = Iter\slice([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5], 5); - self::assertSame([0, 1, 2, 3, 4, 5], Iter\to_array($result)); + static::assertSame([0, 1, 2, 3, 4, 5], Iter\to_array($result)); } public function testSliceWithLength(): void { $result = Iter\slice([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5], 5, 3); - self::assertSame([0, 1, 2], Iter\to_array($result)); + static::assertSame([0, 1, 2], Iter\to_array($result)); } public function testSliceWithZeroLength(): void { $result = Iter\slice([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5], 5, 0); - self::assertSame([], Iter\to_array($result)); + static::assertSame([], Iter\to_array($result)); } public function testSliceThrowsIfStartIsNegative(): void diff --git a/tests/Psl/Iter/TakeTest.php b/tests/Psl/Iter/TakeTest.php index c2840281..d2284aab 100644 --- a/tests/Psl/Iter/TakeTest.php +++ b/tests/Psl/Iter/TakeTest.php @@ -8,13 +8,13 @@ use Psl; use Psl\Iter; -class TakeTest extends TestCase +final class TakeTest extends TestCase { public function testTake(): void { $result = Iter\take(Iter\to_iterator([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]), 3); - self::assertSame([-5, -4, -3], Iter\to_array($result)); + static::assertSame([-5, -4, -3], Iter\to_array($result)); } public function testTakeThrowsIfLengthIsNegative(): void diff --git a/tests/Psl/Iter/TakeWhileTest.php b/tests/Psl/Iter/TakeWhileTest.php index 035b9404..20fa2fbf 100644 --- a/tests/Psl/Iter/TakeWhileTest.php +++ b/tests/Psl/Iter/TakeWhileTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class TakeWhileTest extends TestCase +final class TakeWhileTest extends TestCase { /** * @dataProvider provideData @@ -16,24 +16,24 @@ public function testTakeWhile(array $expected, iterable $iterable, callable $cal { $result = Iter\take_while($iterable, $callable); - self::assertSame($expected, Iter\to_array_with_keys($result)); + static::assertSame($expected, Iter\to_array_with_keys($result)); } public function provideData(): iterable { - yield [[], [1, 2, 3, 4, 5], fn (int $_): bool => false]; - yield [[1, 2, 3], [1, 2, 3, 4, 5], fn (int $i) => $i <= 3]; - yield [[1, 2], [1, 2, 3, 4, 5], fn (int $i) => $i <= 2]; - yield [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], fn (int $_) => true]; - - yield [[], Iter\range(1, 5), fn (int $_): bool => false]; - yield [[1, 2, 3], Iter\range(1, 5), fn (int $i) => $i <= 3]; - yield [[1, 2], Iter\range(1, 5), fn (int $i) => $i <= 2]; - yield [[1, 2, 3, 4, 5], Iter\range(1, 5), fn (int $_) => true]; - - yield [[], Iter\range(1, 5), fn (int $_): bool => false]; - yield [[1, 2 , 3], Iter\range(1, 5), fn (int $i) => $i <= 3]; - yield [[1, 2], Iter\range(1, 5), fn (int $i) => $i <= 2]; - yield [[1, 2, 3, 4, 5], Iter\range(1, 5), fn (int $_) => true]; + yield [[], [1, 2, 3, 4, 5], static fn (int $_): bool => false]; + yield [[1, 2, 3], [1, 2, 3, 4, 5], static fn (int $i) => $i <= 3]; + yield [[1, 2], [1, 2, 3, 4, 5], static fn (int $i) => $i <= 2]; + yield [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], static fn (int $_) => true]; + + yield [[], Iter\range(1, 5), static fn (int $_): bool => false]; + yield [[1, 2, 3], Iter\range(1, 5), static fn (int $i) => $i <= 3]; + yield [[1, 2], Iter\range(1, 5), static fn (int $i) => $i <= 2]; + yield [[1, 2, 3, 4, 5], Iter\range(1, 5), static fn (int $_) => true]; + + yield [[], Iter\range(1, 5), static fn (int $_): bool => false]; + yield [[1, 2 , 3], Iter\range(1, 5), static fn (int $i) => $i <= 3]; + yield [[1, 2], Iter\range(1, 5), static fn (int $i) => $i <= 2]; + yield [[1, 2, 3, 4, 5], Iter\range(1, 5), static fn (int $_) => true]; } } diff --git a/tests/Psl/Iter/ToArrayTest.php b/tests/Psl/Iter/ToArrayTest.php index e596b807..fb55e4bf 100644 --- a/tests/Psl/Iter/ToArrayTest.php +++ b/tests/Psl/Iter/ToArrayTest.php @@ -8,7 +8,7 @@ use Psl\Collection; use Psl\Iter; -class ToArrayTest extends TestCase +final class ToArrayTest extends TestCase { /** * @dataProvider provideToArrayData @@ -17,7 +17,7 @@ public function testToArray(iterable $iterable, array $expected): void { $result = Iter\to_array($iterable); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideToArrayData(): iterable diff --git a/tests/Psl/Iter/ToArrayWithKeysTest.php b/tests/Psl/Iter/ToArrayWithKeysTest.php index 56918d7b..dc1387d2 100644 --- a/tests/Psl/Iter/ToArrayWithKeysTest.php +++ b/tests/Psl/Iter/ToArrayWithKeysTest.php @@ -8,7 +8,7 @@ use Psl\Collection; use Psl\Iter; -class ToArrayWithKeysTest extends TestCase +final class ToArrayWithKeysTest extends TestCase { /** * @dataProvider provideToArrayWithKeysData @@ -17,7 +17,7 @@ public function testToArrayWithKeys(iterable $iterable, array $expected): void { $result = Iter\to_array_with_keys($iterable); - self::assertSame($expected, $result); + static::assertSame($expected, $result); } public function provideToArrayWithKeysData(): iterable diff --git a/tests/Psl/Iter/ToIteratorTest.php b/tests/Psl/Iter/ToIteratorTest.php index ca3872c6..22b8bd7f 100644 --- a/tests/Psl/Iter/ToIteratorTest.php +++ b/tests/Psl/Iter/ToIteratorTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class ToIteratorTest extends TestCase +final class ToIteratorTest extends TestCase { /** * @dataProvider provideToIteratorData @@ -16,8 +16,8 @@ public function testToIterator(array $array): void { $iterator = Iter\to_iterator($array); - self::assertCount(Iter\count($array), $iterator); - self::assertSame($array, Iter\to_array_with_keys($iterator)); + static::assertCount(Iter\count($array), $iterator); + static::assertSame($array, Iter\to_array_with_keys($iterator)); } public function provideToIteratorData(): iterable diff --git a/tests/Psl/Iter/ValuesTest.php b/tests/Psl/Iter/ValuesTest.php index 4593dcc9..10aa3406 100644 --- a/tests/Psl/Iter/ValuesTest.php +++ b/tests/Psl/Iter/ValuesTest.php @@ -8,7 +8,7 @@ use Psl\Collection; use Psl\Iter; -class ValuesTest extends TestCase +final class ValuesTest extends TestCase { /** * @dataProvider provideTestValues diff --git a/tests/Psl/Iter/ZipTest.php b/tests/Psl/Iter/ZipTest.php index 1e0c5a23..e18dd760 100644 --- a/tests/Psl/Iter/ZipTest.php +++ b/tests/Psl/Iter/ZipTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Iter; -class ZipTest extends TestCase +final class ZipTest extends TestCase { public function testZip(): void { @@ -43,6 +43,6 @@ public function testZipWithZeroIterables(): void { $result = Iter\zip(...[]); - self::assertCount(0, $result); + static::assertCount(0, $result); } } diff --git a/tests/Psl/Json/DecodeTest.php b/tests/Psl/Json/DecodeTest.php index 728ce24c..9d2a3db2 100644 --- a/tests/Psl/Json/DecodeTest.php +++ b/tests/Psl/Json/DecodeTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Json; -class DecodeTest extends TestCase +final class DecodeTest extends TestCase { public function testDecode(): void { @@ -19,7 +19,7 @@ public function testDecode(): void "license": "MIT" }'); - self::assertSame([ + static::assertSame([ 'name' => 'azjezz/psl', 'type' => 'library', 'description' => 'PHP Standard Library.', diff --git a/tests/Psl/Json/EncodeTest.php b/tests/Psl/Json/EncodeTest.php index 2ca7a4f1..4e4aa093 100644 --- a/tests/Psl/Json/EncodeTest.php +++ b/tests/Psl/Json/EncodeTest.php @@ -5,9 +5,9 @@ namespace Psl\Json; use PHPUnit\Framework\TestCase; -use Psl\Str; use Psl\Json; use Psl\Math; +use Psl\Str; use const PHP_EOL; @@ -17,7 +17,7 @@ public function testEncode(): void { $actual = Json\encode(['a']); - self::assertSame('["a"]', $actual); + static::assertSame('["a"]', $actual); } public function testPrettyEncode(): void @@ -46,7 +46,7 @@ public function testPrettyEncode(): void } JSON, PHP_EOL, "\n"); - self::assertSame($json, $actual); + static::assertSame($json, $actual); } public function testEncodeThrowsForMalformedUTF8(): void @@ -75,6 +75,6 @@ public function testEncodeThrowsWithInf(): void public function testEncodePreserveZeroFraction(): void { - self::assertSame('1.0', Json\encode(1.0)); + static::assertSame('1.0', Json\encode(1.0)); } } diff --git a/tests/Psl/Json/TypedTest.php b/tests/Psl/Json/TypedTest.php index 28521fe1..8435d02a 100644 --- a/tests/Psl/Json/TypedTest.php +++ b/tests/Psl/Json/TypedTest.php @@ -8,7 +8,7 @@ use Psl\Json; use Psl\Type; -class TypedTest extends TestCase +final class TypedTest extends TestCase { public function testTyped(): void { @@ -20,7 +20,7 @@ public function testTyped(): void "license": "MIT" }', Type\arr(Type\string(), Type\union(Type\string(), Type\arr(Type\int(), Type\string())))); - self::assertSame([ + static::assertSame([ 'name' => 'azjezz/psl', 'type' => 'library', 'description' => 'PHP Standard Library.', @@ -47,13 +47,13 @@ public function testsTypedAsserts(): void { $actual = Json\typed('{"foo": "bar"}', Type\arr(Type\string(), Type\string())); - self::assertSame(['foo' => 'bar'], $actual); + static::assertSame(['foo' => 'bar'], $actual); } public function testTypedCoerce(): void { $actual = Json\typed('{"foo": 123}', Type\arr(Type\string(), Type\string())); - self::assertSame(['foo' => '123'], $actual); + static::assertSame(['foo' => '123'], $actual); } } diff --git a/tests/Psl/Math/AbsTest.php b/tests/Psl/Math/AbsTest.php index e0162ab9..f79680d2 100644 --- a/tests/Psl/Math/AbsTest.php +++ b/tests/Psl/Math/AbsTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Math; -class AbsTest extends TestCase +final class AbsTest extends TestCase { /** * @dataProvider provideData */ public function testAbs($expected, $number): void { - self::assertSame($expected, Math\abs($number)); + static::assertSame($expected, Math\abs($number)); } public function provideData(): array diff --git a/tests/Psl/Math/BaseConvertTest.php b/tests/Psl/Math/BaseConvertTest.php index 387c4198..213b17f2 100644 --- a/tests/Psl/Math/BaseConvertTest.php +++ b/tests/Psl/Math/BaseConvertTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Math; -class BaseConvertTest extends TestCase +final class BaseConvertTest extends TestCase { /** * @dataProvider provideData */ public function testBaseConvert(string $expected, string $value, int $from, int $to): void { - self::assertSame($expected, Math\base_convert($value, $from, $to)); + static::assertSame($expected, Math\base_convert($value, $from, $to)); } public function provideData(): array diff --git a/tests/Psl/Math/CeilTest.php b/tests/Psl/Math/CeilTest.php index 0ef708f9..81fe037f 100644 --- a/tests/Psl/Math/CeilTest.php +++ b/tests/Psl/Math/CeilTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Math; -class CeilTest extends TestCase +final class CeilTest extends TestCase { /** * @dataProvider provideData */ public function testCiel(float $expected, float $number): void { - self::assertSame($expected, Math\ceil($number)); + static::assertSame($expected, Math\ceil($number)); } public function provideData(): array diff --git a/tests/Psl/Math/CosTest.php b/tests/Psl/Math/CosTest.php index 8070c750..3bc01767 100644 --- a/tests/Psl/Math/CosTest.php +++ b/tests/Psl/Math/CosTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Math; -class CosTest extends TestCase +final class CosTest extends TestCase { /** * @dataProvider provideData */ public function testCos(float $expected, float $number): void { - self::assertSame($expected, Math\cos($number)); + static::assertSame($expected, Math\cos($number)); } public function provideData(): array diff --git a/tests/Psl/Math/DivTest.php b/tests/Psl/Math/DivTest.php index 2df4d058..96e8e140 100644 --- a/tests/Psl/Math/DivTest.php +++ b/tests/Psl/Math/DivTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Math; -class DivTest extends TestCase +final class DivTest extends TestCase { /** * @dataProvider provideData */ public function testDiv(int $expected, int $numerator, int $denominator): void { - self::assertSame($expected, Math\div($numerator, $denominator)); + static::assertSame($expected, Math\div($numerator, $denominator)); } public function testDivByZero(): void diff --git a/tests/Psl/Math/ExpTest.php b/tests/Psl/Math/ExpTest.php index c58cd4be..370c64da 100644 --- a/tests/Psl/Math/ExpTest.php +++ b/tests/Psl/Math/ExpTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Math; -class ExpTest extends TestCase +final class ExpTest extends TestCase { /** * @dataProvider provideData */ public function testExp(float $expected, float $number): void { - self::assertSame($expected, Math\exp($number)); + static::assertSame($expected, Math\exp($number)); } public function provideData(): array diff --git a/tests/Psl/Math/FloorTest.php b/tests/Psl/Math/FloorTest.php index fb3e875b..02d7d90b 100644 --- a/tests/Psl/Math/FloorTest.php +++ b/tests/Psl/Math/FloorTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Math; -class FloorTest extends TestCase +final class FloorTest extends TestCase { /** * @dataProvider provideData */ public function testFloor(float $expected, float $number): void { - self::assertSame($expected, Math\floor($number)); + static::assertSame($expected, Math\floor($number)); } public function provideData(): array diff --git a/tests/Psl/Math/FromBaseTest.php b/tests/Psl/Math/FromBaseTest.php index c156e5a9..47066c28 100644 --- a/tests/Psl/Math/FromBaseTest.php +++ b/tests/Psl/Math/FromBaseTest.php @@ -8,14 +8,14 @@ use Psl\Exception; use Psl\Math; -class FromBaseTest extends TestCase +final class FromBaseTest extends TestCase { /** * @dataProvider provideData */ public function testFromBase(int $expected, string $value, int $from_base): void { - self::assertSame($expected, Math\from_base($value, $from_base)); + static::assertSame($expected, Math\from_base($value, $from_base)); } public function provideData(): array diff --git a/tests/Psl/Math/LogTest.php b/tests/Psl/Math/LogTest.php index e42facfd..bbf627db 100644 --- a/tests/Psl/Math/LogTest.php +++ b/tests/Psl/Math/LogTest.php @@ -8,14 +8,14 @@ use Psl\Exception; use Psl\Math; -class LogTest extends TestCase +final class LogTest extends TestCase { /** * @dataProvider provideData */ public function testLog(float $expected, float $number, ?float $base = null): void { - self::assertSame($expected, Math\log($number, $base)); + static::assertSame($expected, Math\log($number, $base)); } public function provideData(): array diff --git a/tests/Psl/Math/MaxByTest.php b/tests/Psl/Math/MaxByTest.php index 2c00d99e..9e7fef14 100644 --- a/tests/Psl/Math/MaxByTest.php +++ b/tests/Psl/Math/MaxByTest.php @@ -4,51 +4,50 @@ namespace Psl\Tests\Math; +use Generator; use PHPUnit\Framework\TestCase; use Psl\Arr; use Psl\Math; use Psl\Str; -class MaxByTest extends TestCase +final class MaxByTest extends TestCase { /** * @dataProvider provideData */ public function testMaxBy($expected, array $values, callable $fun): void { - self::assertSame($expected, Math\max_by($values, $fun)); + static::assertSame($expected, Math\max_by($values, $fun)); } - public function provideData(): array + public function provideData(): Generator { - return [ - [ - 'bazqux', - ['foo', 'bar', 'baz', 'qux', 'foobar', 'bazqux'], - fn ($value) => Str\length($value) - ], + yield [ + 'bazqux', + ['foo', 'bar', 'baz', 'qux', 'foobar', 'bazqux'], + static fn ($value) => Str\length($value), + ]; + yield [ + ['foo', 'bar', 'baz'], [ - ['foo', 'bar', 'baz'], - [ - ['foo'], - ['foo', 'bar'], - ['foo', 'bar', 'baz'] - ], - fn ($arr) => Arr\count($arr) + ['foo'], + ['foo', 'bar'], + ['foo', 'bar', 'baz'] ], + static fn ($arr) => Arr\count($arr), + ]; - [ - 9, - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], - fn ($i) => $i - ], + yield [ + 9, + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], + static fn ($i) => $i, + ]; - [ - null, - [], - fn ($i) => $i - ] + yield [ + null, + [], + static fn ($i) => $i, ]; } } diff --git a/tests/Psl/Math/MaxTest.php b/tests/Psl/Math/MaxTest.php index d58693c8..14a956d6 100644 --- a/tests/Psl/Math/MaxTest.php +++ b/tests/Psl/Math/MaxTest.php @@ -5,17 +5,16 @@ namespace Psl\Tests\Math; use PHPUnit\Framework\TestCase; -use Psl\Iter; use Psl\Math; -class MaxTest extends TestCase +final class MaxTest extends TestCase { /** * @dataProvider provideData */ public function testMax($expected, array $numbers): void { - self::assertSame($expected, Math\max($numbers)); + static::assertSame($expected, Math\max($numbers)); } public function provideData(): array diff --git a/tests/Psl/Math/MaxvaTest.php b/tests/Psl/Math/MaxvaTest.php index 3dbe0dc1..ebcfb9d2 100644 --- a/tests/Psl/Math/MaxvaTest.php +++ b/tests/Psl/Math/MaxvaTest.php @@ -8,14 +8,14 @@ use Psl\Iter; use Psl\Math; -class MaxvaTest extends TestCase +final class MaxvaTest extends TestCase { /** * @dataProvider provideData */ public function testMaxva($expected, $first, $second, ...$rest): void { - self::assertSame($expected, Math\maxva($first, $second, ...$rest)); + static::assertSame($expected, Math\maxva($first, $second, ...$rest)); } public function provideData(): array diff --git a/tests/Psl/Math/MeanTest.php b/tests/Psl/Math/MeanTest.php index 38c23304..9117699b 100644 --- a/tests/Psl/Math/MeanTest.php +++ b/tests/Psl/Math/MeanTest.php @@ -6,17 +6,16 @@ use PHPUnit\Framework\TestCase; use Psl\Arr; -use Psl\Iter; use Psl\Math; -class MeanTest extends TestCase +final class MeanTest extends TestCase { /** * @dataProvider provideData */ public function testMean($expected, array $numbers): void { - self::assertSame($expected, Math\mean($numbers)); + static::assertSame($expected, Math\mean($numbers)); } public function provideData(): array diff --git a/tests/Psl/Math/MedianTest.php b/tests/Psl/Math/MedianTest.php index fa0a33b2..cac5580f 100644 --- a/tests/Psl/Math/MedianTest.php +++ b/tests/Psl/Math/MedianTest.php @@ -9,14 +9,14 @@ use Psl\Iter; use Psl\Math; -class MedianTest extends TestCase +final class MedianTest extends TestCase { /** * @dataProvider provideData */ public function testMedian($expected, array $numbers): void { - self::assertSame($expected, Math\median($numbers)); + static::assertSame($expected, Math\median($numbers)); } public function provideData(): array diff --git a/tests/Psl/Math/MinByTest.php b/tests/Psl/Math/MinByTest.php index e3dc2eb5..870ed01f 100644 --- a/tests/Psl/Math/MinByTest.php +++ b/tests/Psl/Math/MinByTest.php @@ -4,51 +4,50 @@ namespace Psl\Tests\Math; +use Generator; use PHPUnit\Framework\TestCase; use Psl\Iter; use Psl\Math; use Psl\Str; -class MinByTest extends TestCase +final class MinByTest extends TestCase { /** * @dataProvider provideData */ public function testMinBy($expected, array $values, callable $fun): void { - self::assertSame($expected, Math\min_by($values, $fun)); + static::assertSame($expected, Math\min_by($values, $fun)); } - public function provideData(): array + public function provideData(): Generator { - return [ - [ - 'qux', - ['foo', 'bar', 'baz', 'qux', 'foobar', 'bazqux'], - fn ($value) => Str\length($value) - ], + yield [ + 'qux', + ['foo', 'bar', 'baz', 'qux', 'foobar', 'bazqux'], + static fn ($value) => Str\length($value), + ]; + yield [ + ['foo'], [ ['foo'], - [ - ['foo'], - ['foo', 'bar'], - ['foo', 'bar', 'baz'] - ], - fn ($arr) => Iter\count($arr) + ['foo', 'bar'], + ['foo', 'bar', 'baz'] ], + static fn ($arr) => Iter\count($arr), + ]; - [ - 0, - [...Iter\range(0, 9)], - fn ($i) => $i - ], + yield [ + 0, + [...Iter\range(0, 9)], + static fn ($i) => $i, + ]; - [ - null, - [], - fn ($i) => $i - ] + yield [ + null, + [], + static fn ($i) => $i, ]; } } diff --git a/tests/Psl/Math/MinTest.php b/tests/Psl/Math/MinTest.php index ee4a60a2..d92ee0cf 100644 --- a/tests/Psl/Math/MinTest.php +++ b/tests/Psl/Math/MinTest.php @@ -8,7 +8,7 @@ use Psl\Iter; use Psl\Math; -class MinTest extends TestCase +final class MinTest extends TestCase { /** @@ -16,7 +16,7 @@ class MinTest extends TestCase */ public function testMin($expected, array $numbers): void { - self::assertSame($expected, Math\min($numbers)); + static::assertSame($expected, Math\min($numbers)); } public function provideData(): array diff --git a/tests/Psl/Math/MinvaTest.php b/tests/Psl/Math/MinvaTest.php index 919b1ed6..4d1b79e0 100644 --- a/tests/Psl/Math/MinvaTest.php +++ b/tests/Psl/Math/MinvaTest.php @@ -8,14 +8,14 @@ use Psl\Iter; use Psl\Math; -class MinvaTest extends TestCase +final class MinvaTest extends TestCase { /** * @dataProvider provideData */ public function testMainva($expected, $first, $second, ...$rest): void { - self::assertSame($expected, Math\minva($first, $second, ...$rest)); + static::assertSame($expected, Math\minva($first, $second, ...$rest)); } public function provideData(): array diff --git a/tests/Psl/Math/RoundTest.php b/tests/Psl/Math/RoundTest.php index 7f0c56c2..4c060a4b 100644 --- a/tests/Psl/Math/RoundTest.php +++ b/tests/Psl/Math/RoundTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Math; -class RoundTest extends TestCase +final class RoundTest extends TestCase { /** @@ -15,7 +15,7 @@ class RoundTest extends TestCase */ public function testRound(float $expected, float $number, int $precision = 0): void { - self::assertSame($expected, Math\round($number, $precision)); + static::assertSame($expected, Math\round($number, $precision)); } public function provideData(): array diff --git a/tests/Psl/Math/SinTest.php b/tests/Psl/Math/SinTest.php index e812a23a..a5037eb4 100644 --- a/tests/Psl/Math/SinTest.php +++ b/tests/Psl/Math/SinTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Math; -class SinTest extends TestCase +final class SinTest extends TestCase { /** @@ -15,7 +15,7 @@ class SinTest extends TestCase */ public function testSin(float $expected, float $number): void { - self::assertSame($expected, Math\sin($number)); + static::assertSame($expected, Math\sin($number)); } public function provideData(): array diff --git a/tests/Psl/Math/SqrtTest.php b/tests/Psl/Math/SqrtTest.php index 3286fce5..67686820 100644 --- a/tests/Psl/Math/SqrtTest.php +++ b/tests/Psl/Math/SqrtTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Math; -class SqrtTest extends TestCase +final class SqrtTest extends TestCase { /** @@ -15,7 +15,7 @@ class SqrtTest extends TestCase */ public function testSqrt(float $expected, float $number): void { - self::assertSame($expected, Math\sqrt($number)); + static::assertSame($expected, Math\sqrt($number)); } public function provideData(): array diff --git a/tests/Psl/Math/SumFloatsTest.php b/tests/Psl/Math/SumFloatsTest.php index 176b6d17..86a484e5 100644 --- a/tests/Psl/Math/SumFloatsTest.php +++ b/tests/Psl/Math/SumFloatsTest.php @@ -8,14 +8,14 @@ use Psl\Iter; use Psl\Math; -class SumFloatsTest extends TestCase +final class SumFloatsTest extends TestCase { /** * @dataProvider provideData */ public function testSumFloats(float $expected, array $numbers): void { - self::assertSame($expected, Math\sum_floats($numbers)); + static::assertSame($expected, Math\sum_floats($numbers)); } public function provideData(): array @@ -43,11 +43,11 @@ public function provideData(): array [ 323.54, [ - 19.5, - 15.8, - ...Iter\range(0.5, 45, 5.98), - 52.8, - 64, + 19.5, + 15.8, + ...Iter\range(0.5, 45, 5.98), + 52.8, + 64, ] ], ]; diff --git a/tests/Psl/Math/SumTest.php b/tests/Psl/Math/SumTest.php index 9db8f5ba..0ad444fc 100644 --- a/tests/Psl/Math/SumTest.php +++ b/tests/Psl/Math/SumTest.php @@ -8,14 +8,14 @@ use Psl\Iter; use Psl\Math; -class SumTest extends TestCase +final class SumTest extends TestCase { /** * @dataProvider provideData */ public function testSum(int $expected, array $numbers): void { - self::assertSame($expected, Math\sum($numbers)); + static::assertSame($expected, Math\sum($numbers)); } public function provideData(): array diff --git a/tests/Psl/Math/TanTest.php b/tests/Psl/Math/TanTest.php index 45769521..0c60812a 100644 --- a/tests/Psl/Math/TanTest.php +++ b/tests/Psl/Math/TanTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Math; -class TanTest extends TestCase +final class TanTest extends TestCase { /** @@ -15,7 +15,7 @@ class TanTest extends TestCase */ public function testTan(float $expected, float $number): void { - self::assertSame($expected, Math\tan($number)); + static::assertSame($expected, Math\tan($number)); } public function provideData(): array diff --git a/tests/Psl/Math/ToBaseTest.php b/tests/Psl/Math/ToBaseTest.php index 78f93c7f..3ad39c40 100644 --- a/tests/Psl/Math/ToBaseTest.php +++ b/tests/Psl/Math/ToBaseTest.php @@ -8,7 +8,7 @@ use Psl\Exception; use Psl\Math; -class ToBaseTest extends TestCase +final class ToBaseTest extends TestCase { /** @@ -16,7 +16,7 @@ class ToBaseTest extends TestCase */ public function testFromBase(string $expected, int $value, int $to_base): void { - self::assertSame($expected, Math\to_base($value, $to_base)); + static::assertSame($expected, Math\to_base($value, $to_base)); } public function provideData(): array diff --git a/tests/Psl/Password/PasswordTest.php b/tests/Psl/Password/PasswordTest.php index da0358a6..636e2561 100644 --- a/tests/Psl/Password/PasswordTest.php +++ b/tests/Psl/Password/PasswordTest.php @@ -18,17 +18,17 @@ public function testAlgorithms(): void { $algorithms = Password\algorithms(); - self::assertContains(Password\DEFAULT_ALGORITHM, $algorithms); - self::assertContains(Password\BCRYPT_ALGORITHM, $algorithms); - self::assertContains(Password\ARGON2I_ALGORITHM, $algorithms); - self::assertContains(Password\ARGON2ID_ALGORITHM, $algorithms); + static::assertContains(Password\DEFAULT_ALGORITHM, $algorithms); + static::assertContains(Password\BCRYPT_ALGORITHM, $algorithms); + static::assertContains(Password\ARGON2I_ALGORITHM, $algorithms); + static::assertContains(Password\ARGON2ID_ALGORITHM, $algorithms); $algos = Arr\map( password_algos(), - fn (string $value): string => PASSWORD_BCRYPT === $value ? Password\BCRYPT_ALGORITHM : $value + static fn (string $value): string => PASSWORD_BCRYPT === $value ? Password\BCRYPT_ALGORITHM : $value ); - self::assertSame($algos, $algorithms); + static::assertSame($algos, $algorithms); } /** @@ -40,13 +40,13 @@ public function testBcrypt(string $password): void 'cost' => 8 ]); - self::assertTrue(Password\verify($password, $hash)); + static::assertTrue(Password\verify($password, $hash)); $information = Password\get_information($hash); - self::assertSame(Password\BCRYPT_ALGORITHM, $information['algorithm']); - self::assertSame(8, $information['options']['cost']); + static::assertSame(Password\BCRYPT_ALGORITHM, $information['algorithm']); + static::assertSame(8, $information['options']['cost']); - self::assertFalse(Password\needs_rehash($hash, Password\BCRYPT_ALGORITHM, [ + static::assertFalse(Password\needs_rehash($hash, Password\BCRYPT_ALGORITHM, [ 'cost' => 8 ])); } @@ -58,15 +58,15 @@ public function testArgon2i(string $password): void { $hash = Password\hash($password, Password\ARGON2I_ALGORITHM); - self::assertTrue(Password\verify($password, $hash)); + static::assertTrue(Password\verify($password, $hash)); $information = Password\get_information($hash); - self::assertSame(Password\ARGON2I_ALGORITHM, $information['algorithm']); - self::assertSame(Password\ARGON2_DEFAULT_MEMORY_COST, $information['options']['memory_cost']); - self::assertSame(Password\ARGON2_DEFAULT_TIME_COST, $information['options']['time_cost']); - self::assertSame(Password\ARGON2_DEFAULT_THREADS, $information['options']['threads']); + static::assertSame(Password\ARGON2I_ALGORITHM, $information['algorithm']); + static::assertSame(Password\ARGON2_DEFAULT_MEMORY_COST, $information['options']['memory_cost']); + static::assertSame(Password\ARGON2_DEFAULT_TIME_COST, $information['options']['time_cost']); + static::assertSame(Password\ARGON2_DEFAULT_THREADS, $information['options']['threads']); - self::assertFalse(Password\needs_rehash($hash, Password\ARGON2I_ALGORITHM)); + static::assertFalse(Password\needs_rehash($hash, Password\ARGON2I_ALGORITHM)); } public function providePasswords(): iterable diff --git a/tests/Psl/PseudoRandom/FloatTest.php b/tests/Psl/PseudoRandom/FloatTest.php index 18f75f54..cd0eff44 100644 --- a/tests/Psl/PseudoRandom/FloatTest.php +++ b/tests/Psl/PseudoRandom/FloatTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\PseudoRandom; -class FloatTest extends TestCase +final class FloatTest extends TestCase { public function testFloat(): void { $random = PseudoRandom\float(); - self::assertIsFloat($random); - self::assertGreaterThanOrEqual(0, $random); - self::assertLessThanOrEqual(1, $random); + static::assertIsFloat($random); + static::assertGreaterThanOrEqual(0, $random); + static::assertLessThanOrEqual(1, $random); } } diff --git a/tests/Psl/PseudoRandom/IntTest.php b/tests/Psl/PseudoRandom/IntTest.php index d2db6b57..9975bbca 100644 --- a/tests/Psl/PseudoRandom/IntTest.php +++ b/tests/Psl/PseudoRandom/IntTest.php @@ -9,33 +9,33 @@ use Psl\Math; use Psl\PseudoRandom; -class IntTest extends TestCase +final class IntTest extends TestCase { public function testInt(): void { $random = PseudoRandom\int(); - self::assertIsInt($random); - self::assertGreaterThanOrEqual(Math\INT64_MIN, $random); - self::assertLessThanOrEqual(Math\INT64_MAX, $random); + static::assertIsInt($random); + static::assertGreaterThanOrEqual(Math\INT64_MIN, $random); + static::assertLessThanOrEqual(Math\INT64_MAX, $random); } public function testIntWithASpecificMin(): void { $random = PseudoRandom\int(10); - self::assertIsInt($random); - self::assertGreaterThanOrEqual(10, $random); - self::assertLessThanOrEqual(Math\INT64_MAX, $random); + static::assertIsInt($random); + static::assertGreaterThanOrEqual(10, $random); + static::assertLessThanOrEqual(Math\INT64_MAX, $random); } public function testIntWithASpecificRange(): void { $random = PseudoRandom\int(20, 1200); - self::assertIsInt($random); - self::assertGreaterThanOrEqual(20, $random); - self::assertLessThanOrEqual(1200, $random); + static::assertIsInt($random); + static::assertGreaterThanOrEqual(20, $random); + static::assertLessThanOrEqual(1200, $random); } public function testIntWithMinGreaterThanMax(): void diff --git a/tests/Psl/Result/FailureTest.php b/tests/Psl/Result/FailureTest.php index d6a1c195..c3c66317 100644 --- a/tests/Psl/Result/FailureTest.php +++ b/tests/Psl/Result/FailureTest.php @@ -8,20 +8,19 @@ use PHPUnit\Framework\TestCase; use Psl\Fun; use Psl\Result\Failure; -use stdClass; -class FailureTest extends TestCase +final class FailureTest extends TestCase { public function testIsSucceeded(): void { $wrapper = new Failure(new Exception('foo')); - self::assertFalse($wrapper->isSucceeded()); + static::assertFalse($wrapper->isSucceeded()); } public function testIsFailed(): void { $wrapper = new Failure(new Exception('foo')); - self::assertTrue($wrapper->isFailed()); + static::assertTrue($wrapper->isFailed()); } public function testGetResult(): void @@ -38,7 +37,7 @@ public function testGetException(): void $exception = new Exception('bar'); $wrapper = new Failure($exception); $e = $wrapper->getException(); - self::assertSame($exception, $e); + static::assertSame($exception, $e); } public function testProceed(): void @@ -50,7 +49,7 @@ public function testProceed(): void static fn (Exception $exception): int => 404 ); - self::assertSame(404, $actual); + static::assertSame(404, $actual); } public function testThenToSuccess(): void @@ -59,13 +58,13 @@ public function testThenToSuccess(): void $wrapper = new Failure($exception); $actual = $wrapper->then( static function () { - throw new \Exception('Dont call us, we\'ll call you!'); + throw new Exception('Dont call us, we\'ll call you!'); }, static fn (Exception $exception): string => $exception->getMessage() ); - self::assertTrue($actual->isSucceeded()); - self::assertSame($actual->getResult(), 'bar'); + static::assertTrue($actual->isSucceeded()); + static::assertSame($actual->getResult(), 'bar'); } public function testThenToFailure(): void @@ -74,12 +73,12 @@ public function testThenToFailure(): void $wrapper = new Failure($exception); $actual = $wrapper->then( static function () { - throw new \Exception('Dont call us, we\'ll call you!'); + throw new Exception('Dont call us, we\'ll call you!'); }, Fun\rethrow() ); - self::assertFalse($actual->isSucceeded()); - self::assertSame($actual->getException(), $exception); + static::assertFalse($actual->isSucceeded()); + static::assertSame($actual->getException(), $exception); } } diff --git a/tests/Psl/Result/SuccessTest.php b/tests/Psl/Result/SuccessTest.php index 8a71d040..1aad6dda 100644 --- a/tests/Psl/Result/SuccessTest.php +++ b/tests/Psl/Result/SuccessTest.php @@ -6,29 +6,28 @@ use Exception; use PHPUnit\Framework\TestCase; +use Psl\Exception\InvariantViolationException; use Psl\Fun; use Psl\Result\Success; -use Psl\Exception\InvariantViolationException; -use stdClass; -class SuccessTest extends TestCase +final class SuccessTest extends TestCase { public function testIsSucceeded(): void { $wrapper = new Success('hello'); - self::assertTrue($wrapper->isSucceeded()); + static::assertTrue($wrapper->isSucceeded()); } public function testIsFailed(): void { $wrapper = new Success('hello'); - self::assertFalse($wrapper->isFailed()); + static::assertFalse($wrapper->isFailed()); } public function testGetResult(): void { $wrapper = new Success('hello'); - self::assertSame('hello', $wrapper->getResult()); + static::assertSame('hello', $wrapper->getResult()); } public function testGetException(): void @@ -49,7 +48,7 @@ public function testProceed(): void static fn (Exception $exception): int => 404 ); - self::assertSame(200, $actual); + static::assertSame(200, $actual); } public function testThenToSuccess(): void @@ -60,9 +59,9 @@ public function testThenToSuccess(): void Fun\rethrow() ); - self::assertNotSame($wrapper, $actual); - self::assertTrue($actual->isSucceeded()); - self::assertSame('hello', $actual->getResult()); + static::assertNotSame($wrapper, $actual); + static::assertTrue($actual->isSucceeded()); + static::assertSame('hello', $actual->getResult()); } public function testThenToFailure(): void @@ -76,7 +75,7 @@ static function () use ($exception) { Fun\rethrow() ); - self::assertFalse($actual->isSucceeded()); - self::assertSame($actual->getException(), $exception); + static::assertFalse($actual->isSucceeded()); + static::assertSame($actual->getException(), $exception); } } diff --git a/tests/Psl/Result/WrapTest.php b/tests/Psl/Result/WrapTest.php index f955887d..ac8511e6 100644 --- a/tests/Psl/Result/WrapTest.php +++ b/tests/Psl/Result/WrapTest.php @@ -4,21 +4,22 @@ namespace Psl\Tests\Result; +use Exception; use PHPUnit\Framework\TestCase; -use Psl\Result; use Psl\Exception\InvariantViolationException; +use Psl\Result; -class WrapTest extends TestCase +final class WrapTest extends TestCase { public function testWrapException(): void { - $exception = new \Exception('foo'); + $exception = new Exception('foo'); $wrapper = Result\wrap(static function () use ($exception): void { throw $exception; }); - self::assertFalse($wrapper->isSucceeded()); - self::assertTrue($wrapper->isFailed()); - self::assertSame($exception, $wrapper->getException()); + static::assertFalse($wrapper->isSucceeded()); + static::assertTrue($wrapper->isFailed()); + static::assertSame($exception, $wrapper->getException()); $this->expectExceptionObject($exception); @@ -30,9 +31,9 @@ public function testWrapResult(): void $wrapper = Result\wrap(static function (): string { return 'foo'; }); - self::assertTrue($wrapper->isSucceeded()); - self::assertFalse($wrapper->isFailed()); - self::assertSame('foo', $wrapper->getResult()); + static::assertTrue($wrapper->isSucceeded()); + static::assertFalse($wrapper->isFailed()); + static::assertSame('foo', $wrapper->getResult()); $this->expectException(InvariantViolationException::class); $this->expectExceptionMessage('No exception thrown'); diff --git a/tests/Psl/SecureRandom/BytesTest.php b/tests/Psl/SecureRandom/BytesTest.php index 8af5eb2e..fdc24410 100644 --- a/tests/Psl/SecureRandom/BytesTest.php +++ b/tests/Psl/SecureRandom/BytesTest.php @@ -9,18 +9,18 @@ use Psl\SecureRandom; use Psl\Str; -class BytesTest extends TestCase +final class BytesTest extends TestCase { public function testBytes(): void { $random = SecureRandom\bytes(32); - self::assertSame(32, Str\Byte\length($random)); + static::assertSame(32, Str\Byte\length($random)); } public function testBytesEarlyReturnForZeroLength(): void { - self::assertSame('', SecureRandom\bytes(0)); + static::assertSame('', SecureRandom\bytes(0)); } public function testBytesThrowsForNegativeLength(): void diff --git a/tests/Psl/SecureRandom/FloatTest.php b/tests/Psl/SecureRandom/FloatTest.php index 759eb0fb..0fa0bf12 100644 --- a/tests/Psl/SecureRandom/FloatTest.php +++ b/tests/Psl/SecureRandom/FloatTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\SecureRandom; -class FloatTest extends TestCase +final class FloatTest extends TestCase { public function testFloat(): void { $random = SecureRandom\float(); - self::assertIsFloat($random); - self::assertGreaterThanOrEqual(0, $random); - self::assertLessThanOrEqual(1, $random); + static::assertIsFloat($random); + static::assertGreaterThanOrEqual(0, $random); + static::assertLessThanOrEqual(1, $random); } } diff --git a/tests/Psl/SecureRandom/IntTest.php b/tests/Psl/SecureRandom/IntTest.php index 916ee2e1..d0dd7a6c 100644 --- a/tests/Psl/SecureRandom/IntTest.php +++ b/tests/Psl/SecureRandom/IntTest.php @@ -9,33 +9,33 @@ use Psl\Math; use Psl\SecureRandom; -class IntTest extends TestCase +final class IntTest extends TestCase { public function testInt(): void { $random = SecureRandom\int(); - self::assertIsInt($random); - self::assertGreaterThanOrEqual(Math\INT64_MIN, $random); - self::assertLessThanOrEqual(Math\INT64_MAX, $random); + static::assertIsInt($random); + static::assertGreaterThanOrEqual(Math\INT64_MIN, $random); + static::assertLessThanOrEqual(Math\INT64_MAX, $random); } public function testIntWithASpecificMin(): void { $random = SecureRandom\int(10); - self::assertIsInt($random); - self::assertGreaterThanOrEqual(10, $random); - self::assertLessThanOrEqual(Math\INT64_MAX, $random); + static::assertIsInt($random); + static::assertGreaterThanOrEqual(10, $random); + static::assertLessThanOrEqual(Math\INT64_MAX, $random); } public function testIntWithASpecificRange(): void { $random = SecureRandom\int(20, 1200); - self::assertIsInt($random); - self::assertGreaterThanOrEqual(20, $random); - self::assertLessThanOrEqual(1200, $random); + static::assertIsInt($random); + static::assertGreaterThanOrEqual(20, $random); + static::assertLessThanOrEqual(1200, $random); } public function testIntWithMinGreaterThanMax(): void diff --git a/tests/Psl/SecureRandom/StringTest.php b/tests/Psl/SecureRandom/StringTest.php index 00107844..853f0a41 100644 --- a/tests/Psl/SecureRandom/StringTest.php +++ b/tests/Psl/SecureRandom/StringTest.php @@ -9,15 +9,15 @@ use Psl\SecureRandom; use Psl\Str; -class StringTest extends TestCase +final class StringTest extends TestCase { public function testString(): void { $random = SecureRandom\string(32); - self::assertSame(32, Str\length($random)); + static::assertSame(32, Str\length($random)); foreach (Str\chunk($random) as $char) { - self::assertTrue(Str\contains(Str\ALPHABET_ALPHANUMERIC, $char)); + static::assertTrue(Str\contains(Str\ALPHABET_ALPHANUMERIC, $char)); } } @@ -25,15 +25,15 @@ public function testStringWithSpecificChars(): void { $random = SecureRandom\string(32, 'abc'); - self::assertSame(32, Str\length($random)); + static::assertSame(32, Str\length($random)); foreach (Str\chunk($random) as $char) { - self::assertTrue(Str\contains('abc', $char)); + static::assertTrue(Str\contains('abc', $char)); } } public function testStringEarlyReturnForZeroLength(): void { - self::assertSame('', SecureRandom\string(0)); + static::assertSame('', SecureRandom\string(0)); } public function testStringThrowsForNegativeLength(): void diff --git a/tests/Psl/SequenceTest.php b/tests/Psl/SequenceTest.php index a4da0600..ec2989e6 100644 --- a/tests/Psl/SequenceTest.php +++ b/tests/Psl/SequenceTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl; -class SequenceTest extends TestCase +final class SequenceTest extends TestCase { /** * @dataProvider provideData */ public function testSequence(array $args, $expected): void { - self::assertSame($expected, Psl\sequence(...$args)); + static::assertSame($expected, Psl\sequence(...$args)); } public function provideData(): iterable diff --git a/tests/Psl/Str/Byte/CapitalizeTest.php b/tests/Psl/Str/Byte/CapitalizeTest.php index 1e16529c..d1616c48 100644 --- a/tests/Psl/Str/Byte/CapitalizeTest.php +++ b/tests/Psl/Str/Byte/CapitalizeTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class CapitalizeTest extends TestCase +final class CapitalizeTest extends TestCase { /** * @dataProvider provideData */ public function testCapitalize(string $expected, string $value): void { - self::assertSame($expected, Byte\capitalize($value)); + static::assertSame($expected, Byte\capitalize($value)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/CapitalizeWordsTest.php b/tests/Psl/Str/Byte/CapitalizeWordsTest.php index 9d31f25f..ca6416cf 100644 --- a/tests/Psl/Str/Byte/CapitalizeWordsTest.php +++ b/tests/Psl/Str/Byte/CapitalizeWordsTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class CapitalizeWordsTest extends TestCase +final class CapitalizeWordsTest extends TestCase { /** * @dataProvider provideData */ public function testCapitalizeWords(string $expected, string $value): void { - self::assertSame($expected, Byte\capitalize_words($value)); + static::assertSame($expected, Byte\capitalize_words($value)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/ChrTest.php b/tests/Psl/Str/Byte/ChrTest.php index fdc6135a..848776ab 100644 --- a/tests/Psl/Str/Byte/ChrTest.php +++ b/tests/Psl/Str/Byte/ChrTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class ChrTest extends TestCase +final class ChrTest extends TestCase { /** * @dataProvider provideData */ public function testChr(string $expected, int $value): void { - self::assertSame($expected, Byte\chr($value)); + static::assertSame($expected, Byte\chr($value)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/ChunkTest.php b/tests/Psl/Str/Byte/ChunkTest.php index a8df5435..42cc77fe 100644 --- a/tests/Psl/Str/Byte/ChunkTest.php +++ b/tests/Psl/Str/Byte/ChunkTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class ChunkTest extends TestCase +final class ChunkTest extends TestCase { /** * @dataProvider provideData */ public function testCapitalize(array $expected, string $value, int $chunk_size = 1): void { - self::assertSame($expected, Byte\chunk($value, $chunk_size)); + static::assertSame($expected, Byte\chunk($value, $chunk_size)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/CompareCiTest.php b/tests/Psl/Str/Byte/CompareCiTest.php index 4a28fe36..8645bc4a 100644 --- a/tests/Psl/Str/Byte/CompareCiTest.php +++ b/tests/Psl/Str/Byte/CompareCiTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class CompareCiTest extends TestCase +final class CompareCiTest extends TestCase { /** * @dataProvider provideData @@ -17,11 +17,11 @@ public function testCompareCi(int $expected, string $str1, string $str2, ?int $l $diff = Byte\compare_ci($str1, $str2, $length); if (0 === $expected) { - self::assertSame(0, $diff); + static::assertSame(0, $diff); } elseif (0 > $expected) { - self::assertLessThanOrEqual(-1, $diff); + static::assertLessThanOrEqual(-1, $diff); } else { - self::assertGreaterThanOrEqual(1, $diff); + static::assertGreaterThanOrEqual(1, $diff); } } diff --git a/tests/Psl/Str/Byte/CompareTest.php b/tests/Psl/Str/Byte/CompareTest.php index ca5b3dc5..ae808ac7 100644 --- a/tests/Psl/Str/Byte/CompareTest.php +++ b/tests/Psl/Str/Byte/CompareTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class CompareTest extends TestCase +final class CompareTest extends TestCase { /** * @dataProvider provideData @@ -17,11 +17,11 @@ public function testCompare(int $expected, string $str1, string $str2, ?int $len $diff = Byte\compare($str1, $str2, $length); if (0 === $expected) { - self::assertSame(0, $diff); + static::assertSame(0, $diff); } elseif (0 > $expected) { - self::assertLessThanOrEqual(-1, $diff); + static::assertLessThanOrEqual(-1, $diff); } else { - self::assertGreaterThanOrEqual(1, $diff); + static::assertGreaterThanOrEqual(1, $diff); } } diff --git a/tests/Psl/Str/Byte/ContainsCiTest.php b/tests/Psl/Str/Byte/ContainsCiTest.php index 23ffa977..2e9e39ae 100644 --- a/tests/Psl/Str/Byte/ContainsCiTest.php +++ b/tests/Psl/Str/Byte/ContainsCiTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class ContainsCiTest extends TestCase +final class ContainsCiTest extends TestCase { /** * @dataProvider provideData */ public function testContainsCi(bool $expected, string $haystack, string $needle, int $offset = 0): void { - self::assertSame($expected, Byte\contains_ci($haystack, $needle, $offset)); + static::assertSame($expected, Byte\contains_ci($haystack, $needle, $offset)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/ContainsTest.php b/tests/Psl/Str/Byte/ContainsTest.php index 6b546a6d..d6cb6fb7 100644 --- a/tests/Psl/Str/Byte/ContainsTest.php +++ b/tests/Psl/Str/Byte/ContainsTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class ContainsTest extends TestCase +final class ContainsTest extends TestCase { /** * @dataProvider provideData */ public function testContains(bool $expected, string $haystack, string $needle, int $offset = 0): void { - self::assertSame($expected, Byte\contains($haystack, $needle, $offset)); + static::assertSame($expected, Byte\contains($haystack, $needle, $offset)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/EndsWithCiTest.php b/tests/Psl/Str/Byte/EndsWithCiTest.php index 5bf5b244..41c4f7d8 100644 --- a/tests/Psl/Str/Byte/EndsWithCiTest.php +++ b/tests/Psl/Str/Byte/EndsWithCiTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class EndsWithCiTest extends TestCase +final class EndsWithCiTest extends TestCase { /** * @dataProvider provideData */ public function testEndsWithCi(bool $expected, string $haystack, string $suffix): void { - self::assertSame($expected, Byte\ends_with_ci($haystack, $suffix)); + static::assertSame($expected, Byte\ends_with_ci($haystack, $suffix)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/EndsWithTest.php b/tests/Psl/Str/Byte/EndsWithTest.php index 56208282..438701ab 100644 --- a/tests/Psl/Str/Byte/EndsWithTest.php +++ b/tests/Psl/Str/Byte/EndsWithTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class EndsWithTest extends TestCase +final class EndsWithTest extends TestCase { /** * @dataProvider provideData */ public function testEndsWith(bool $expected, string $haystack, string $suffix): void { - self::assertSame($expected, Byte\ends_with($haystack, $suffix)); + static::assertSame($expected, Byte\ends_with($haystack, $suffix)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/LengthTest.php b/tests/Psl/Str/Byte/LengthTest.php index cc99d5bd..477ba9fa 100644 --- a/tests/Psl/Str/Byte/LengthTest.php +++ b/tests/Psl/Str/Byte/LengthTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class LengthTest extends TestCase +final class LengthTest extends TestCase { /** * @dataProvider provideData */ public function testLength(int $expected, string $str): void { - self::assertSame($expected, Byte\length($str)); + static::assertSame($expected, Byte\length($str)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/LowercaseTest.php b/tests/Psl/Str/Byte/LowercaseTest.php index 0b647423..67c729ce 100644 --- a/tests/Psl/Str/Byte/LowercaseTest.php +++ b/tests/Psl/Str/Byte/LowercaseTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class LowercaseTest extends TestCase +final class LowercaseTest extends TestCase { /** * @dataProvider provideData */ public function testLowercase(string $expected, string $str): void { - self::assertSame($expected, Byte\lowercase($str)); + static::assertSame($expected, Byte\lowercase($str)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/OrdTest.php b/tests/Psl/Str/Byte/OrdTest.php index 78f62bc0..3072d794 100644 --- a/tests/Psl/Str/Byte/OrdTest.php +++ b/tests/Psl/Str/Byte/OrdTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class OrdTest extends TestCase +final class OrdTest extends TestCase { /** * @dataProvider provideData */ public function testOrd(int $expected, string $value): void { - self::assertSame($expected, Byte\ord($value)); + static::assertSame($expected, Byte\ord($value)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/PadLeftTest.php b/tests/Psl/Str/Byte/PadLeftTest.php index 25d93327..43556e8d 100644 --- a/tests/Psl/Str/Byte/PadLeftTest.php +++ b/tests/Psl/Str/Byte/PadLeftTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class PadLeftTest extends TestCase +final class PadLeftTest extends TestCase { /** * @dataProvider provideData */ public function testPadLeft(string $expected, string $str, int $total_length, string $pad_string = ' '): void { - self::assertSame($expected, Byte\pad_left($str, $total_length, $pad_string)); + static::assertSame($expected, Byte\pad_left($str, $total_length, $pad_string)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/PadRightTest.php b/tests/Psl/Str/Byte/PadRightTest.php index 5585dbe9..421b583d 100644 --- a/tests/Psl/Str/Byte/PadRightTest.php +++ b/tests/Psl/Str/Byte/PadRightTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class PadRightTest extends TestCase +final class PadRightTest extends TestCase { /** * @dataProvider provideData */ public function testPadRight(string $expected, string $str, int $total_length, string $pad_string = ' '): void { - self::assertSame($expected, Byte\pad_right($str, $total_length, $pad_string)); + static::assertSame($expected, Byte\pad_right($str, $total_length, $pad_string)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/ReplaceCiTest.php b/tests/Psl/Str/Byte/ReplaceCiTest.php index b640f2e7..ac08f88f 100644 --- a/tests/Psl/Str/Byte/ReplaceCiTest.php +++ b/tests/Psl/Str/Byte/ReplaceCiTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class ReplaceCiTest extends TestCase +final class ReplaceCiTest extends TestCase { /** * @dataProvider provideData */ public function testReplaceCi(string $expected, string $haystack, string $needle, string $replacement): void { - self::assertSame($expected, Byte\replace_ci($haystack, $needle, $replacement)); + static::assertSame($expected, Byte\replace_ci($haystack, $needle, $replacement)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/ReplaceEveryCiTest.php b/tests/Psl/Str/Byte/ReplaceEveryCiTest.php index 643088ed..434a6499 100644 --- a/tests/Psl/Str/Byte/ReplaceEveryCiTest.php +++ b/tests/Psl/Str/Byte/ReplaceEveryCiTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class ReplaceEveryCiTest extends TestCase +final class ReplaceEveryCiTest extends TestCase { /** * @dataProvider provideData */ public function testReplaceEveryCi(string $expected, string $haystack, iterable $replacements): void { - self::assertSame($expected, Byte\replace_every_ci($haystack, $replacements)); + static::assertSame($expected, Byte\replace_every_ci($haystack, $replacements)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/ReplaceEveryTest.php b/tests/Psl/Str/Byte/ReplaceEveryTest.php index 2ee09900..20bdbb37 100644 --- a/tests/Psl/Str/Byte/ReplaceEveryTest.php +++ b/tests/Psl/Str/Byte/ReplaceEveryTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class ReplaceEveryTest extends TestCase +final class ReplaceEveryTest extends TestCase { /** * @dataProvider provideData */ public function testReplaceEvery(string $expected, string $haystack, iterable $replacements): void { - self::assertSame($expected, Byte\replace_every($haystack, $replacements)); + static::assertSame($expected, Byte\replace_every($haystack, $replacements)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/ReplaceTest.php b/tests/Psl/Str/Byte/ReplaceTest.php index e2f1fd6c..50fe0b1c 100644 --- a/tests/Psl/Str/Byte/ReplaceTest.php +++ b/tests/Psl/Str/Byte/ReplaceTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class ReplaceTest extends TestCase +final class ReplaceTest extends TestCase { /** * @dataProvider provideData */ public function testReplace(string $expected, string $haystack, string $needle, string $replacement): void { - self::assertSame($expected, Byte\replace($haystack, $needle, $replacement)); + static::assertSame($expected, Byte\replace($haystack, $needle, $replacement)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/ReverseTest.php b/tests/Psl/Str/Byte/ReverseTest.php index 634d3645..75a375c9 100644 --- a/tests/Psl/Str/Byte/ReverseTest.php +++ b/tests/Psl/Str/Byte/ReverseTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class ReverseTest extends TestCase +final class ReverseTest extends TestCase { /** * @dataProvider provideData */ public function testReverse(string $expected, string $input): void { - self::assertSame($expected, Byte\reverse($input)); + static::assertSame($expected, Byte\reverse($input)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/Rot13Test.php b/tests/Psl/Str/Byte/Rot13Test.php index bb59de01..3f781b11 100644 --- a/tests/Psl/Str/Byte/Rot13Test.php +++ b/tests/Psl/Str/Byte/Rot13Test.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class Rot13Test extends TestCase +final class Rot13Test extends TestCase { /** * @dataProvider provideData */ public function testWords(string $expected, string $string): void { - self::assertSame($expected, Byte\rot13($string)); + static::assertSame($expected, Byte\rot13($string)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/SearchCiTest.php b/tests/Psl/Str/Byte/SearchCiTest.php index 78da302f..836a887f 100644 --- a/tests/Psl/Str/Byte/SearchCiTest.php +++ b/tests/Psl/Str/Byte/SearchCiTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class SearchCiTest extends TestCase +final class SearchCiTest extends TestCase { /** @@ -15,7 +15,7 @@ class SearchCiTest extends TestCase */ public function testSearchCi(?int $expected, string $haystack, string $needle, int $offset = 0): void { - self::assertSame($expected, Byte\search_ci($haystack, $needle, $offset)); + static::assertSame($expected, Byte\search_ci($haystack, $needle, $offset)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/SearchLastTest.php b/tests/Psl/Str/Byte/SearchLastTest.php index 823d0064..7e255e1e 100644 --- a/tests/Psl/Str/Byte/SearchLastTest.php +++ b/tests/Psl/Str/Byte/SearchLastTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class SearchLastTest extends TestCase +final class SearchLastTest extends TestCase { /** @@ -15,7 +15,7 @@ class SearchLastTest extends TestCase */ public function testSearchLast(?int $expected, string $haystack, string $needle, int $offset = 0): void { - self::assertSame($expected, Byte\search_last($haystack, $needle, $offset)); + static::assertSame($expected, Byte\search_last($haystack, $needle, $offset)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/SearchTest.php b/tests/Psl/Str/Byte/SearchTest.php index 3a926a21..f8afe8d0 100644 --- a/tests/Psl/Str/Byte/SearchTest.php +++ b/tests/Psl/Str/Byte/SearchTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class SearchTest extends TestCase +final class SearchTest extends TestCase { /** @@ -15,7 +15,7 @@ class SearchTest extends TestCase */ public function testSearch(?int $expected, string $haystack, string $needle, int $offset = 0): void { - self::assertSame($expected, Byte\search($haystack, $needle, $offset)); + static::assertSame($expected, Byte\search($haystack, $needle, $offset)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/ShuffleTest.php b/tests/Psl/Str/Byte/ShuffleTest.php index 6ea46167..5957daac 100644 --- a/tests/Psl/Str/Byte/ShuffleTest.php +++ b/tests/Psl/Str/Byte/ShuffleTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class ShuffleTest extends TestCase +final class ShuffleTest extends TestCase { /** * @dataProvider provideData @@ -15,10 +15,10 @@ class ShuffleTest extends TestCase public function testShuffle(string $str): void { $shuffled = Byte\shuffle($str); - self::assertSame(Byte\length($str), Byte\length($shuffled)); + static::assertSame(Byte\length($str), Byte\length($shuffled)); if (Byte\length($shuffled) > 1) { - self::assertNotSame($str, $shuffled); + static::assertNotSame($str, $shuffled); } } diff --git a/tests/Psl/Str/Byte/SliceTest.php b/tests/Psl/Str/Byte/SliceTest.php index 22ebcbf2..738f7184 100644 --- a/tests/Psl/Str/Byte/SliceTest.php +++ b/tests/Psl/Str/Byte/SliceTest.php @@ -8,7 +8,7 @@ use Psl\Exception; use Psl\Str\Byte; -class SliceTest extends TestCase +final class SliceTest extends TestCase { /** @@ -16,7 +16,7 @@ class SliceTest extends TestCase */ public function testSlice(string $expected, string $string, int $offset, ?int $length = null): void { - self::assertSame($expected, Byte\slice($string, $offset, $length)); + static::assertSame($expected, Byte\slice($string, $offset, $length)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/SpliceTest.php b/tests/Psl/Str/Byte/SpliceTest.php index 8d923222..34e21acf 100644 --- a/tests/Psl/Str/Byte/SpliceTest.php +++ b/tests/Psl/Str/Byte/SpliceTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class SpliceTest extends TestCase +final class SpliceTest extends TestCase { /** * @dataProvider provideData @@ -19,7 +19,7 @@ public function testSplice( int $offset, ?int $length = null ): void { - self::assertSame($expected, Byte\splice($string, $replacement, $offset, $length)); + static::assertSame($expected, Byte\splice($string, $replacement, $offset, $length)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/SplitTest.php b/tests/Psl/Str/Byte/SplitTest.php index f0e8a9b3..365fbbe1 100644 --- a/tests/Psl/Str/Byte/SplitTest.php +++ b/tests/Psl/Str/Byte/SplitTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class SplitTest extends TestCase +final class SplitTest extends TestCase { /** * @dataProvider provideData */ public function testSplit(array $expected, string $string, string $delimiter, ?int $length = null): void { - self::assertSame($expected, Byte\split($string, $delimiter, $length)); + static::assertSame($expected, Byte\split($string, $delimiter, $length)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/StartsWithCiTest.php b/tests/Psl/Str/Byte/StartsWithCiTest.php index de9ea28a..58680607 100644 --- a/tests/Psl/Str/Byte/StartsWithCiTest.php +++ b/tests/Psl/Str/Byte/StartsWithCiTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class StartsWithCiTest extends TestCase +final class StartsWithCiTest extends TestCase { /** * @dataProvider provideData */ public function testStartsWithCi(bool $expected, string $haystack, string $prefix): void { - self::assertSame($expected, Byte\starts_with_ci($haystack, $prefix)); + static::assertSame($expected, Byte\starts_with_ci($haystack, $prefix)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/StartsWithTest.php b/tests/Psl/Str/Byte/StartsWithTest.php index 2fd7b6b2..5016b018 100644 --- a/tests/Psl/Str/Byte/StartsWithTest.php +++ b/tests/Psl/Str/Byte/StartsWithTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class StartsWithTest extends TestCase +final class StartsWithTest extends TestCase { /** @@ -15,7 +15,7 @@ class StartsWithTest extends TestCase */ public function testStartsWith(bool $expected, string $haystack, string $prefix): void { - self::assertSame($expected, Byte\starts_with($haystack, $prefix)); + static::assertSame($expected, Byte\starts_with($haystack, $prefix)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/StripPrefixTest.php b/tests/Psl/Str/Byte/StripPrefixTest.php index 740cb88c..f2ebbfe4 100644 --- a/tests/Psl/Str/Byte/StripPrefixTest.php +++ b/tests/Psl/Str/Byte/StripPrefixTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class StripPrefixTest extends TestCase +final class StripPrefixTest extends TestCase { /** * @dataProvider provideData */ public function testStripPrefix(string $expected, string $haystack, string $prefix): void { - self::assertSame($expected, Byte\strip_prefix($haystack, $prefix)); + static::assertSame($expected, Byte\strip_prefix($haystack, $prefix)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/StripSuffixTest.php b/tests/Psl/Str/Byte/StripSuffixTest.php index e35d262b..ecc411a7 100644 --- a/tests/Psl/Str/Byte/StripSuffixTest.php +++ b/tests/Psl/Str/Byte/StripSuffixTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class StripSuffixTest extends TestCase +final class StripSuffixTest extends TestCase { /** * @dataProvider provideData */ public function testStripSuffix(string $expected, string $haystack, string $suffix): void { - self::assertSame($expected, Byte\strip_suffix($haystack, $suffix)); + static::assertSame($expected, Byte\strip_suffix($haystack, $suffix)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/TrimLeftTest.php b/tests/Psl/Str/Byte/TrimLeftTest.php index 52cab5c6..2eada418 100644 --- a/tests/Psl/Str/Byte/TrimLeftTest.php +++ b/tests/Psl/Str/Byte/TrimLeftTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class TrimLeftTest extends TestCase +final class TrimLeftTest extends TestCase { /** @@ -15,7 +15,7 @@ class TrimLeftTest extends TestCase */ public function testTrimLeft(string $expected, string $string, ?string $chars = null): void { - self::assertSame($expected, Byte\trim_left($string, $chars)); + static::assertSame($expected, Byte\trim_left($string, $chars)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/TrimRightTest.php b/tests/Psl/Str/Byte/TrimRightTest.php index c2b6453f..2bdbc1bd 100644 --- a/tests/Psl/Str/Byte/TrimRightTest.php +++ b/tests/Psl/Str/Byte/TrimRightTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class TrimRightTest extends TestCase +final class TrimRightTest extends TestCase { /** @@ -15,7 +15,7 @@ class TrimRightTest extends TestCase */ public function testTrimRight(string $expected, string $string, ?string $chars = null): void { - self::assertSame($expected, Byte\trim_right($string, $chars)); + static::assertSame($expected, Byte\trim_right($string, $chars)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/TrimTest.php b/tests/Psl/Str/Byte/TrimTest.php index bb6b50e2..12afc2a4 100644 --- a/tests/Psl/Str/Byte/TrimTest.php +++ b/tests/Psl/Str/Byte/TrimTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class TrimTest extends TestCase +final class TrimTest extends TestCase { /** * @dataProvider provideData */ public function testTrim(string $expected, string $string, ?string $chars = null): void { - self::assertSame($expected, Byte\trim($string, $chars)); + static::assertSame($expected, Byte\trim($string, $chars)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/UppercaseTest.php b/tests/Psl/Str/Byte/UppercaseTest.php index 5bc64017..4b618db0 100644 --- a/tests/Psl/Str/Byte/UppercaseTest.php +++ b/tests/Psl/Str/Byte/UppercaseTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class UppercaseTest extends TestCase +final class UppercaseTest extends TestCase { /** @@ -15,7 +15,7 @@ class UppercaseTest extends TestCase */ public function testUppercase(string $expected, string $str): void { - self::assertSame($expected, Byte\uppercase($str)); + static::assertSame($expected, Byte\uppercase($str)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/WordsTest.php b/tests/Psl/Str/Byte/WordsTest.php index 035fdce0..0b00f986 100644 --- a/tests/Psl/Str/Byte/WordsTest.php +++ b/tests/Psl/Str/Byte/WordsTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str\Byte; -class WordsTest extends TestCase +final class WordsTest extends TestCase { /** @@ -15,7 +15,7 @@ class WordsTest extends TestCase */ public function testWords(array $expected, string $string, ?string $extra_chars = null): void { - self::assertSame($expected, Byte\words($string, $extra_chars)); + static::assertSame($expected, Byte\words($string, $extra_chars)); } public function provideData(): array diff --git a/tests/Psl/Str/Byte/WrapTest.php b/tests/Psl/Str/Byte/WrapTest.php index 21b19bca..e8e250dc 100644 --- a/tests/Psl/Str/Byte/WrapTest.php +++ b/tests/Psl/Str/Byte/WrapTest.php @@ -5,10 +5,9 @@ namespace Psl\Tests\Str\Byte; use PHPUnit\Framework\TestCase; -use Psl\Str; use Psl\Str\Byte; -class WrapTest extends TestCase +final class WrapTest extends TestCase { /** * @dataProvider provideData @@ -20,7 +19,7 @@ public function testWrap( string $break = "\n", bool $cut = false ): void { - self::assertSame($expected, Byte\wrap($str, $width, $break, $cut)); + static::assertSame($expected, Byte\wrap($str, $width, $break, $cut)); } public function provideData(): array diff --git a/tests/Psl/Str/CapitalizeTest.php b/tests/Psl/Str/CapitalizeTest.php index 0d18a3f2..a6967d1c 100644 --- a/tests/Psl/Str/CapitalizeTest.php +++ b/tests/Psl/Str/CapitalizeTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class CapitalizeTest extends TestCase +final class CapitalizeTest extends TestCase { /** * @dataProvider provideData */ public function testCapitalize(string $expected, string $value): void { - self::assertSame($expected, Str\capitalize($value)); + static::assertSame($expected, Str\capitalize($value)); } public function provideData(): array diff --git a/tests/Psl/Str/CapitalizeWordsTest.php b/tests/Psl/Str/CapitalizeWordsTest.php index d534e00c..376f26b0 100644 --- a/tests/Psl/Str/CapitalizeWordsTest.php +++ b/tests/Psl/Str/CapitalizeWordsTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class CapitalizeWordsTest extends TestCase +final class CapitalizeWordsTest extends TestCase { /** @@ -15,7 +15,7 @@ class CapitalizeWordsTest extends TestCase */ public function testCapitalizeWords(string $expected, string $value): void { - self::assertSame($expected, Str\capitalize_words($value)); + static::assertSame($expected, Str\capitalize_words($value)); } public function provideData(): array diff --git a/tests/Psl/Str/ChrTest.php b/tests/Psl/Str/ChrTest.php index 45c1f63d..14620c2d 100644 --- a/tests/Psl/Str/ChrTest.php +++ b/tests/Psl/Str/ChrTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class ChrTest extends TestCase +final class ChrTest extends TestCase { /** * @dataProvider provideData */ public function testChr(string $expected, int $value): void { - self::assertSame($expected, Str\chr($value)); + static::assertSame($expected, Str\chr($value)); } public function provideData(): array diff --git a/tests/Psl/Str/ChunkTest.php b/tests/Psl/Str/ChunkTest.php index 2cf14329..20037ce6 100644 --- a/tests/Psl/Str/ChunkTest.php +++ b/tests/Psl/Str/ChunkTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class ChunkTest extends TestCase +final class ChunkTest extends TestCase { /** @@ -15,7 +15,7 @@ class ChunkTest extends TestCase */ public function testCapitalize(array $expected, string $value, int $chunk_size = 1): void { - self::assertSame($expected, Str\chunk($value, $chunk_size)); + static::assertSame($expected, Str\chunk($value, $chunk_size)); } public function provideData(): array diff --git a/tests/Psl/Str/ConcatTest.php b/tests/Psl/Str/ConcatTest.php index 58fc3c12..9c6cd3d7 100644 --- a/tests/Psl/Str/ConcatTest.php +++ b/tests/Psl/Str/ConcatTest.php @@ -7,12 +7,12 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class ConcatTest extends TestCase +final class ConcatTest extends TestCase { public function testConcat(): void { - self::assertSame('', Str\concat('')); - self::assertSame('abc', Str\concat('a', 'b', 'c')); - self::assertSame('مرحبا بكم', Str\concat(...['م', 'ر', 'ح', 'ب', 'ا', ' ', 'ب', 'ك', 'م'])); + static::assertSame('', Str\concat('')); + static::assertSame('abc', Str\concat('a', 'b', 'c')); + static::assertSame('مرحبا بكم', Str\concat(...['م', 'ر', 'ح', 'ب', 'ا', ' ', 'ب', 'ك', 'م'])); } } diff --git a/tests/Psl/Str/ContainsCiTest.php b/tests/Psl/Str/ContainsCiTest.php index cacdfa85..0f0095ef 100644 --- a/tests/Psl/Str/ContainsCiTest.php +++ b/tests/Psl/Str/ContainsCiTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class ContainsCiTest extends TestCase +final class ContainsCiTest extends TestCase { /** * @dataProvider provideData */ public function testContainsCi(bool $expected, string $haystack, string $needle, int $offset = 0): void { - self::assertSame($expected, Str\contains_ci($haystack, $needle, $offset)); + static::assertSame($expected, Str\contains_ci($haystack, $needle, $offset)); } public function provideData(): array diff --git a/tests/Psl/Str/ContainsTest.php b/tests/Psl/Str/ContainsTest.php index b13a1416..2d398130 100644 --- a/tests/Psl/Str/ContainsTest.php +++ b/tests/Psl/Str/ContainsTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class ContainsTest extends TestCase +final class ContainsTest extends TestCase { /** * @dataProvider provideData */ public function testContains(bool $expected, string $haystack, string $needle, int $offset = 0): void { - self::assertSame($expected, Str\contains($haystack, $needle, $offset)); + static::assertSame($expected, Str\contains($haystack, $needle, $offset)); } public function provideData(): array diff --git a/tests/Psl/Str/ConvertEncodingTest.php b/tests/Psl/Str/ConvertEncodingTest.php index e19e46a4..d6d4095f 100644 --- a/tests/Psl/Str/ConvertEncodingTest.php +++ b/tests/Psl/Str/ConvertEncodingTest.php @@ -19,7 +19,7 @@ public function testConvertEncoding( string $from_encoding, string $to_encoding ): void { - self::assertSame($expected, Str\convert_encoding($string, $from_encoding, $to_encoding)); + static::assertSame($expected, Str\convert_encoding($string, $from_encoding, $to_encoding)); } public function provideData(): array diff --git a/tests/Psl/Str/DetectEncodingTest.php b/tests/Psl/Str/DetectEncodingTest.php index 630abf50..8c2adbb6 100644 --- a/tests/Psl/Str/DetectEncodingTest.php +++ b/tests/Psl/Str/DetectEncodingTest.php @@ -14,7 +14,7 @@ final class DetectEncodingTest extends TestCase */ public function testDetectEncoding(?string $expected, string $string): void { - self::assertSame($expected, Str\detect_encoding($string)); + static::assertSame($expected, Str\detect_encoding($string)); } public function provideData(): array diff --git a/tests/Psl/Str/EndsWithCiTest.php b/tests/Psl/Str/EndsWithCiTest.php index 4af846aa..789f5e5a 100644 --- a/tests/Psl/Str/EndsWithCiTest.php +++ b/tests/Psl/Str/EndsWithCiTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class EndsWithCiTest extends TestCase +final class EndsWithCiTest extends TestCase { /** * @dataProvider provideData @@ -15,9 +15,9 @@ class EndsWithCiTest extends TestCase public function testEndsWithCi(bool $expected, string $haystack, string $suffix): void { if (null === Str\search_ci($haystack, $suffix)) { - self::assertFalse(Str\ends_with_ci($haystack, $suffix)); + static::assertFalse(Str\ends_with_ci($haystack, $suffix)); } else { - self::assertSame($expected, Str\ends_with_ci($haystack, $suffix)); + static::assertSame($expected, Str\ends_with_ci($haystack, $suffix)); } } diff --git a/tests/Psl/Str/EndsWithTest.php b/tests/Psl/Str/EndsWithTest.php index 8bd0c745..ab135d5d 100644 --- a/tests/Psl/Str/EndsWithTest.php +++ b/tests/Psl/Str/EndsWithTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class EndsWithTest extends TestCase +final class EndsWithTest extends TestCase { /** * @dataProvider provideData */ public function testEndsWith(bool $expected, string $haystack, string $suffix): void { - self::assertSame($expected, Str\ends_with($haystack, $suffix)); + static::assertSame($expected, Str\ends_with($haystack, $suffix)); } public function provideData(): array diff --git a/tests/Psl/Str/FoldTest.php b/tests/Psl/Str/FoldTest.php index 1d1ae9b5..a69df59c 100644 --- a/tests/Psl/Str/FoldTest.php +++ b/tests/Psl/Str/FoldTest.php @@ -7,10 +7,10 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class FoldTest extends TestCase +final class FoldTest extends TestCase { public function testFold(): void { - self::assertSame('ssoo', Str\fold('ẞOO')); + static::assertSame('ssoo', Str\fold('ẞOO')); } } diff --git a/tests/Psl/Str/FormatNumberTest.php b/tests/Psl/Str/FormatNumberTest.php index 0204eb4e..0830ca5e 100644 --- a/tests/Psl/Str/FormatNumberTest.php +++ b/tests/Psl/Str/FormatNumberTest.php @@ -7,10 +7,10 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class FormatNumberTest extends TestCase +final class FormatNumberTest extends TestCase { public function testFormatNumber(): void { - self::assertSame('487 891,49', Str\format_number(487891.4879, 2, ',', ' ')); + static::assertSame('487 891,49', Str\format_number(487891.4879, 2, ',', ' ')); } } diff --git a/tests/Psl/Str/FromCodePointsTest.php b/tests/Psl/Str/FromCodePointsTest.php index 5d7e8f9f..0a9c9537 100644 --- a/tests/Psl/Str/FromCodePointsTest.php +++ b/tests/Psl/Str/FromCodePointsTest.php @@ -7,20 +7,20 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class FromCodePointsTest extends TestCase +final class FromCodePointsTest extends TestCase { public function testFromCodePoints(): void { - self::assertSame(/* NULL = */ Str\chr(0), Str\from_code_points(0)); + static::assertSame(/* NULL = */ Str\chr(0), Str\from_code_points(0)); - self::assertSame('مرحبا بكم', Str\from_code_points(1605, 1585, 1581, 1576, 1575, 32, 1576, 1603, 1605)); + static::assertSame('مرحبا بكم', Str\from_code_points(1605, 1585, 1581, 1576, 1575, 32, 1576, 1603, 1605)); - self::assertSame('Hello', Str\from_code_points(72, 101, 108, 108, 111)); + static::assertSame('Hello', Str\from_code_points(72, 101, 108, 108, 111)); - self::assertSame('ẞoo!', Str\from_code_points(7838, 111, 111, 33)); + static::assertSame('ẞoo!', Str\from_code_points(7838, 111, 111, 33)); - self::assertSame('ς', Str\from_code_points(962)); + static::assertSame('ς', Str\from_code_points(962)); - self::assertSame("\u{10001}", Str\from_code_points(65537)); + static::assertSame("\u{10001}", Str\from_code_points(65537)); } } diff --git a/tests/Psl/Str/IsEmptyTest.php b/tests/Psl/Str/IsEmptyTest.php index 411a081d..a318c946 100644 --- a/tests/Psl/Str/IsEmptyTest.php +++ b/tests/Psl/Str/IsEmptyTest.php @@ -7,12 +7,12 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class IsEmptyTest extends TestCase +final class IsEmptyTest extends TestCase { public function testIsEmpty(): void { - self::assertTrue(Str\is_empty('')); - self::assertFalse(Str\is_empty(Str\chr(0))); - self::assertFalse(Str\is_empty('hello')); + static::assertTrue(Str\is_empty('')); + static::assertFalse(Str\is_empty(Str\chr(0))); + static::assertFalse(Str\is_empty('hello')); } } diff --git a/tests/Psl/Str/IsUTF8Test.php b/tests/Psl/Str/IsUTF8Test.php index b821251c..38af19f9 100644 --- a/tests/Psl/Str/IsUTF8Test.php +++ b/tests/Psl/Str/IsUTF8Test.php @@ -14,7 +14,7 @@ final class IsUTF8Test extends TestCase */ public function testIsUTF8Test(bool $expected, string $string): void { - self::assertSame($expected, Str\is_utf8($string)); + static::assertSame($expected, Str\is_utf8($string)); } public function provideData(): array diff --git a/tests/Psl/Str/JoinTest.php b/tests/Psl/Str/JoinTest.php index 5cd46ad7..b18d364e 100644 --- a/tests/Psl/Str/JoinTest.php +++ b/tests/Psl/Str/JoinTest.php @@ -7,12 +7,12 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class JoinTest extends TestCase +final class JoinTest extends TestCase { public function testJoin(): void { - self::assertSame('abc', Str\join(['a', 'b', 'c'], '')); - self::assertSame('Hello, World', Str\join(['Hello', 'World'], ', ')); - self::assertSame('foo / bar / baz', Str\join(['foo', 'bar', 'baz'], ' / ')); + static::assertSame('abc', Str\join(['a', 'b', 'c'], '')); + static::assertSame('Hello, World', Str\join(['Hello', 'World'], ', ')); + static::assertSame('foo / bar / baz', Str\join(['foo', 'bar', 'baz'], ' / ')); } } diff --git a/tests/Psl/Str/LengthTest.php b/tests/Psl/Str/LengthTest.php index a9bad58a..a3e6aff3 100644 --- a/tests/Psl/Str/LengthTest.php +++ b/tests/Psl/Str/LengthTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class LengthTest extends TestCase +final class LengthTest extends TestCase { /** * @dataProvider provideData */ public function testLength(int $expected, string $str): void { - self::assertSame($expected, Str\length($str)); + static::assertSame($expected, Str\length($str)); } public function provideData(): array diff --git a/tests/Psl/Str/LevenshteinTest.php b/tests/Psl/Str/LevenshteinTest.php index 034203ef..1f5363a1 100644 --- a/tests/Psl/Str/LevenshteinTest.php +++ b/tests/Psl/Str/LevenshteinTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class LevenshteinTest extends TestCase +final class LevenshteinTest extends TestCase { /** * @dataProvider provideData @@ -20,7 +20,7 @@ public function testLevenshtein( ?int $cor = null, ?int $cod = null ): void { - self::assertSame($expected, Str\levenshtein($a, $b, $coi, $cor, $cod)); + static::assertSame($expected, Str\levenshtein($a, $b, $coi, $cor, $cod)); } public function provideData(): array diff --git a/tests/Psl/Str/LowercaseTest.php b/tests/Psl/Str/LowercaseTest.php index 247e3b77..ba3e25f5 100644 --- a/tests/Psl/Str/LowercaseTest.php +++ b/tests/Psl/Str/LowercaseTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class LowercaseTest extends TestCase +final class LowercaseTest extends TestCase { /** * @dataProvider provideData */ public function testLowercase(string $expected, string $str): void { - self::assertSame($expected, Str\lowercase($str)); + static::assertSame($expected, Str\lowercase($str)); } public function provideData(): array diff --git a/tests/Psl/Str/MetaphoneTest.php b/tests/Psl/Str/MetaphoneTest.php index 652fe9cd..9705cf5b 100644 --- a/tests/Psl/Str/MetaphoneTest.php +++ b/tests/Psl/Str/MetaphoneTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class MetaphoneTest extends TestCase +final class MetaphoneTest extends TestCase { /** * @dataProvider provideData */ public function testMetaphone(?string $expected, string $str, int $phonemes = 0): void { - self::assertSame($expected, Str\metaphone($str, $phonemes)); + static::assertSame($expected, Str\metaphone($str, $phonemes)); } public function provideData(): array diff --git a/tests/Psl/Str/OrdTest.php b/tests/Psl/Str/OrdTest.php index 79df8a0e..628a7402 100644 --- a/tests/Psl/Str/OrdTest.php +++ b/tests/Psl/Str/OrdTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class OrdTest extends TestCase +final class OrdTest extends TestCase { /** * @dataProvider provideData */ public function testOrd(int $expected, string $value): void { - self::assertSame($expected, Str\ord($value)); + static::assertSame($expected, Str\ord($value)); } public function provideData(): array diff --git a/tests/Psl/Str/PadLeftTest.php b/tests/Psl/Str/PadLeftTest.php index c26c20af..1518425f 100644 --- a/tests/Psl/Str/PadLeftTest.php +++ b/tests/Psl/Str/PadLeftTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class PadLeftTest extends TestCase +final class PadLeftTest extends TestCase { /** * @dataProvider provideData */ public function testPadLeft(string $expected, string $str, int $total_length, string $pad_string = ' '): void { - self::assertSame($expected, Str\pad_left($str, $total_length, $pad_string)); + static::assertSame($expected, Str\pad_left($str, $total_length, $pad_string)); } public function provideData(): array diff --git a/tests/Psl/Str/PadRightTest.php b/tests/Psl/Str/PadRightTest.php index 324fcdf0..5b6d6d45 100644 --- a/tests/Psl/Str/PadRightTest.php +++ b/tests/Psl/Str/PadRightTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class PadRightTest extends TestCase +final class PadRightTest extends TestCase { /** * @dataProvider provideData */ public function testPadRight(string $expected, string $str, int $total_length, string $pad_string = ' '): void { - self::assertSame($expected, Str\pad_right($str, $total_length, $pad_string)); + static::assertSame($expected, Str\pad_right($str, $total_length, $pad_string)); } public function provideData(): array diff --git a/tests/Psl/Str/RepeatTest.php b/tests/Psl/Str/RepeatTest.php index 4da536d1..129fe811 100644 --- a/tests/Psl/Str/RepeatTest.php +++ b/tests/Psl/Str/RepeatTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class RepeatTest extends TestCase +final class RepeatTest extends TestCase { /** * @dataProvider provideData */ public function testRepeat(string $expected, string $string, int $multiplier): void { - self::assertSame($expected, Str\repeat($string, $multiplier)); + static::assertSame($expected, Str\repeat($string, $multiplier)); } public function provideData(): array diff --git a/tests/Psl/Str/ReplaceCiTest.php b/tests/Psl/Str/ReplaceCiTest.php index 6a5bf3a0..36c4dab1 100644 --- a/tests/Psl/Str/ReplaceCiTest.php +++ b/tests/Psl/Str/ReplaceCiTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class ReplaceCiTest extends TestCase +final class ReplaceCiTest extends TestCase { /** * @dataProvider provideData */ public function testReplaceCi(string $expected, string $haystack, string $needle, string $replacement): void { - self::assertSame($expected, Str\replace_ci($haystack, $needle, $replacement)); + static::assertSame($expected, Str\replace_ci($haystack, $needle, $replacement)); } public function provideData(): array diff --git a/tests/Psl/Str/ReplaceEveryCiTest.php b/tests/Psl/Str/ReplaceEveryCiTest.php index 3a59407c..ef5efa0c 100644 --- a/tests/Psl/Str/ReplaceEveryCiTest.php +++ b/tests/Psl/Str/ReplaceEveryCiTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class ReplaceEveryCiTest extends TestCase +final class ReplaceEveryCiTest extends TestCase { /** * @dataProvider provideData */ public function testReplaceEveryCi(string $expected, string $haystack, iterable $replacements): void { - self::assertSame($expected, Str\replace_every_ci($haystack, $replacements)); + static::assertSame($expected, Str\replace_every_ci($haystack, $replacements)); } public function provideData(): array diff --git a/tests/Psl/Str/ReplaceEveryTest.php b/tests/Psl/Str/ReplaceEveryTest.php index d8ed90a0..3000f1e4 100644 --- a/tests/Psl/Str/ReplaceEveryTest.php +++ b/tests/Psl/Str/ReplaceEveryTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class ReplaceEveryTest extends TestCase +final class ReplaceEveryTest extends TestCase { /** @@ -15,7 +15,7 @@ class ReplaceEveryTest extends TestCase */ public function testReplaceEvery(string $expected, string $haystack, iterable $replacements): void { - self::assertSame($expected, Str\replace_every($haystack, $replacements)); + static::assertSame($expected, Str\replace_every($haystack, $replacements)); } public function provideData(): array diff --git a/tests/Psl/Str/ReplaceTest.php b/tests/Psl/Str/ReplaceTest.php index cc76c0a5..0005cf63 100644 --- a/tests/Psl/Str/ReplaceTest.php +++ b/tests/Psl/Str/ReplaceTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class ReplaceTest extends TestCase +final class ReplaceTest extends TestCase { /** * @dataProvider provideData */ public function testReplace(string $expected, string $haystack, string $needle, string $replacement): void { - self::assertSame($expected, Str\replace($haystack, $needle, $replacement)); + static::assertSame($expected, Str\replace($haystack, $needle, $replacement)); } public function provideData(): array diff --git a/tests/Psl/Str/SearchCiTest.php b/tests/Psl/Str/SearchCiTest.php index 82ac478e..38b9c1da 100644 --- a/tests/Psl/Str/SearchCiTest.php +++ b/tests/Psl/Str/SearchCiTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class SearchCiTest extends TestCase +final class SearchCiTest extends TestCase { /** * @dataProvider provideData */ public function testSearchCi(?int $expected, string $haystack, string $needle, int $offset = 0): void { - self::assertSame($expected, Str\search_ci($haystack, $needle, $offset)); + static::assertSame($expected, Str\search_ci($haystack, $needle, $offset)); } public function provideData(): array diff --git a/tests/Psl/Str/SearchLastCiTest.php b/tests/Psl/Str/SearchLastCiTest.php index 145d48fb..c47c18f4 100644 --- a/tests/Psl/Str/SearchLastCiTest.php +++ b/tests/Psl/Str/SearchLastCiTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class SearchLastCiTest extends TestCase +final class SearchLastCiTest extends TestCase { /** * @dataProvider provideData */ public function testSearchLastCi(?int $expected, string $haystack, string $needle, int $offset = 0): void { - self::assertSame($expected, Str\search_last_ci($haystack, $needle, $offset)); + static::assertSame($expected, Str\search_last_ci($haystack, $needle, $offset)); } public function provideData(): array diff --git a/tests/Psl/Str/SearchLastTest.php b/tests/Psl/Str/SearchLastTest.php index 38f0270e..9d991727 100644 --- a/tests/Psl/Str/SearchLastTest.php +++ b/tests/Psl/Str/SearchLastTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class SearchLastTest extends TestCase +final class SearchLastTest extends TestCase { /** * @dataProvider provideData */ public function testSearchLast(?int $expected, string $haystack, string $needle, int $offset = 0): void { - self::assertSame($expected, Str\search_last($haystack, $needle, $offset)); + static::assertSame($expected, Str\search_last($haystack, $needle, $offset)); } public function provideData(): array diff --git a/tests/Psl/Str/SearchTest.php b/tests/Psl/Str/SearchTest.php index c6c4286d..b78d905b 100644 --- a/tests/Psl/Str/SearchTest.php +++ b/tests/Psl/Str/SearchTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class SearchTest extends TestCase +final class SearchTest extends TestCase { /** * @dataProvider provideData */ public function testSearch(?int $expected, string $haystack, string $needle, int $offset = 0): void { - self::assertSame($expected, Str\search($haystack, $needle, $offset)); + static::assertSame($expected, Str\search($haystack, $needle, $offset)); } public function provideData(): array diff --git a/tests/Psl/Str/SliceTest.php b/tests/Psl/Str/SliceTest.php index 6be5b466..58891f0d 100644 --- a/tests/Psl/Str/SliceTest.php +++ b/tests/Psl/Str/SliceTest.php @@ -8,14 +8,14 @@ use Psl\Exception; use Psl\Str; -class SliceTest extends TestCase +final class SliceTest extends TestCase { /** * @dataProvider provideData */ public function testSlice(string $expected, string $string, int $offset, ?int $length = null): void { - self::assertSame($expected, Str\slice($string, $offset, $length)); + static::assertSame($expected, Str\slice($string, $offset, $length)); } public function provideData(): array diff --git a/tests/Psl/Str/SpliceTest.php b/tests/Psl/Str/SpliceTest.php index f3255b4e..e3f0d8ad 100644 --- a/tests/Psl/Str/SpliceTest.php +++ b/tests/Psl/Str/SpliceTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class SpliceTest extends TestCase +final class SpliceTest extends TestCase { /** * @dataProvider provideData @@ -19,7 +19,7 @@ public function testSplice( int $offset, ?int $length = null ): void { - self::assertSame($expected, Str\splice($string, $replacement, $offset, $length)); + static::assertSame($expected, Str\splice($string, $replacement, $offset, $length)); } public function provideData(): array diff --git a/tests/Psl/Str/SplitTest.php b/tests/Psl/Str/SplitTest.php index 290a5964..5261300f 100644 --- a/tests/Psl/Str/SplitTest.php +++ b/tests/Psl/Str/SplitTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class SplitTest extends TestCase +final class SplitTest extends TestCase { /** * @dataProvider provideData */ public function testSplit(array $expected, string $string, string $delimiter, ?int $length = null): void { - self::assertSame($expected, Str\split($string, $delimiter, $length)); + static::assertSame($expected, Str\split($string, $delimiter, $length)); } public function provideData(): array diff --git a/tests/Psl/Str/StartsWithCiTest.php b/tests/Psl/Str/StartsWithCiTest.php index ca253d14..4399ad4f 100644 --- a/tests/Psl/Str/StartsWithCiTest.php +++ b/tests/Psl/Str/StartsWithCiTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class StartsWithCiTest extends TestCase +final class StartsWithCiTest extends TestCase { /** @@ -15,7 +15,7 @@ class StartsWithCiTest extends TestCase */ public function testStartsWithCi(bool $expected, string $haystack, string $prefix): void { - self::assertSame($expected, Str\starts_with_ci($haystack, $prefix)); + static::assertSame($expected, Str\starts_with_ci($haystack, $prefix)); } public function provideData(): array diff --git a/tests/Psl/Str/StartsWithTest.php b/tests/Psl/Str/StartsWithTest.php index f243c826..418330a0 100644 --- a/tests/Psl/Str/StartsWithTest.php +++ b/tests/Psl/Str/StartsWithTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class StartsWithTest extends TestCase +final class StartsWithTest extends TestCase { /** * @dataProvider provideData */ public function testStartsWith(bool $expected, string $haystack, string $prefix): void { - self::assertSame($expected, Str\starts_with($haystack, $prefix)); + static::assertSame($expected, Str\starts_with($haystack, $prefix)); } public function provideData(): array diff --git a/tests/Psl/Str/StripPrefixTest.php b/tests/Psl/Str/StripPrefixTest.php index a342c51c..271f2522 100644 --- a/tests/Psl/Str/StripPrefixTest.php +++ b/tests/Psl/Str/StripPrefixTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class StripPrefixTest extends TestCase +final class StripPrefixTest extends TestCase { /** * @dataProvider provideData */ public function testStripPrefix(string $expected, string $haystack, string $prefix): void { - self::assertSame($expected, Str\strip_prefix($haystack, $prefix)); + static::assertSame($expected, Str\strip_prefix($haystack, $prefix)); } public function provideData(): array diff --git a/tests/Psl/Str/StripSuffixTest.php b/tests/Psl/Str/StripSuffixTest.php index 58c41301..e1c3d02e 100644 --- a/tests/Psl/Str/StripSuffixTest.php +++ b/tests/Psl/Str/StripSuffixTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class StripSuffixTest extends TestCase +final class StripSuffixTest extends TestCase { /** @@ -15,7 +15,7 @@ class StripSuffixTest extends TestCase */ public function testStripSuffix(string $expected, string $haystack, string $suffix): void { - self::assertSame($expected, Str\strip_suffix($haystack, $suffix)); + static::assertSame($expected, Str\strip_suffix($haystack, $suffix)); } public function provideData(): array diff --git a/tests/Psl/Str/ToIntTest.php b/tests/Psl/Str/ToIntTest.php index c83d7040..3053f525 100644 --- a/tests/Psl/Str/ToIntTest.php +++ b/tests/Psl/Str/ToIntTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class ToIntTest extends TestCase +final class ToIntTest extends TestCase { /** * @dataProvider provideData */ public function testToInt(?int $expected, string $string): void { - self::assertSame($expected, Str\to_int($string)); + static::assertSame($expected, Str\to_int($string)); } public function provideData(): array diff --git a/tests/Psl/Str/TrimLeftTest.php b/tests/Psl/Str/TrimLeftTest.php index 7b7895f8..d713e777 100644 --- a/tests/Psl/Str/TrimLeftTest.php +++ b/tests/Psl/Str/TrimLeftTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class TrimLeftTest extends TestCase +final class TrimLeftTest extends TestCase { /** * @dataProvider provideData */ public function testTrimLeft(string $expected, string $string, ?string $chars = null): void { - self::assertSame($expected, Str\trim_left($string, $chars)); + static::assertSame($expected, Str\trim_left($string, $chars)); } public function provideData(): array diff --git a/tests/Psl/Str/TrimRightTest.php b/tests/Psl/Str/TrimRightTest.php index b703e37f..ac61583f 100644 --- a/tests/Psl/Str/TrimRightTest.php +++ b/tests/Psl/Str/TrimRightTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class TrimRightTest extends TestCase +final class TrimRightTest extends TestCase { /** * @dataProvider provideData */ public function testTrimRight(string $expected, string $string, ?string $chars = null): void { - self::assertSame($expected, Str\trim_right($string, $chars)); + static::assertSame($expected, Str\trim_right($string, $chars)); } public function provideData(): array diff --git a/tests/Psl/Str/TrimTest.php b/tests/Psl/Str/TrimTest.php index 56fb51bf..36521ba7 100644 --- a/tests/Psl/Str/TrimTest.php +++ b/tests/Psl/Str/TrimTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class TrimTest extends TestCase +final class TrimTest extends TestCase { /** * @dataProvider provideData */ public function testTrim(string $expected, string $string, ?string $chars = null): void { - self::assertSame($expected, Str\trim($string, $chars)); + static::assertSame($expected, Str\trim($string, $chars)); } public function provideData(): array diff --git a/tests/Psl/Str/TruncateTest.php b/tests/Psl/Str/TruncateTest.php index 1134b39f..bc67b92b 100644 --- a/tests/Psl/Str/TruncateTest.php +++ b/tests/Psl/Str/TruncateTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class TruncateTest extends TestCase +final class TruncateTest extends TestCase { /** * @dataProvider provideData @@ -19,7 +19,7 @@ public function testTruncate( int $width, ?string $trim_marker = null ): void { - self::assertSame($expected, Str\truncate($str, $offset, $width, $trim_marker)); + static::assertSame($expected, Str\truncate($str, $offset, $width, $trim_marker)); } public function provideData(): array diff --git a/tests/Psl/Str/UppercaseTest.php b/tests/Psl/Str/UppercaseTest.php index 6f1a1aa8..8c494fe4 100644 --- a/tests/Psl/Str/UppercaseTest.php +++ b/tests/Psl/Str/UppercaseTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class UppercaseTest extends TestCase +final class UppercaseTest extends TestCase { /** * @dataProvider provideData */ public function testUppercase(string $expected, string $str): void { - self::assertSame($expected, Str\uppercase($str)); + static::assertSame($expected, Str\uppercase($str)); } public function provideData(): array diff --git a/tests/Psl/Str/WidthTest.php b/tests/Psl/Str/WidthTest.php index 45e99d78..4dc4be2d 100644 --- a/tests/Psl/Str/WidthTest.php +++ b/tests/Psl/Str/WidthTest.php @@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class WidthTest extends TestCase +final class WidthTest extends TestCase { /** * @dataProvider provideData */ public function testWidth(int $expected, string $str): void { - self::assertSame($expected, Str\width($str)); + static::assertSame($expected, Str\width($str)); } public function provideData(): array diff --git a/tests/Psl/Str/WrapTest.php b/tests/Psl/Str/WrapTest.php index 5dd8a843..076425b9 100644 --- a/tests/Psl/Str/WrapTest.php +++ b/tests/Psl/Str/WrapTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Str; -class WrapTest extends TestCase +final class WrapTest extends TestCase { /** * @dataProvider provideData @@ -19,7 +19,7 @@ public function testWrap( string $break = "\n", bool $cut = false ): void { - self::assertSame($expected, Str\wrap($str, $width, $break, $cut)); + static::assertSame($expected, Str\wrap($str, $width, $break, $cut)); } public function provideData(): array diff --git a/tests/Psl/Type/ArrayKeyTypeTest.php b/tests/Psl/Type/ArrayKeyTypeTest.php index 7ed891ce..1aff2222 100644 --- a/tests/Psl/Type/ArrayKeyTypeTest.php +++ b/tests/Psl/Type/ArrayKeyTypeTest.php @@ -6,7 +6,7 @@ use Psl\Type; -class ArrayKeyTypeTest extends TypeTest +final class ArrayKeyTypeTest extends TypeTest { public function getType(): Type\Type { diff --git a/tests/Psl/Type/ArrayTypeTest.php b/tests/Psl/Type/ArrayTypeTest.php index 733aedeb..a464528a 100644 --- a/tests/Psl/Type/ArrayTypeTest.php +++ b/tests/Psl/Type/ArrayTypeTest.php @@ -8,7 +8,7 @@ use Psl\Str; use Psl\Type; -class ArrayTypeTest extends TypeTest +final class ArrayTypeTest extends TypeTest { public function getType(): Type\Type { @@ -21,15 +21,15 @@ public function getValidCoercions(): iterable yield [Iter\range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]; yield [Iter\range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]; yield [ - Iter\map(Iter\range(1, 10), fn (int $value): string => (string) $value), + Iter\map(Iter\range(1, 10), static fn (int $value): string => (string) $value), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ]; yield [ - Iter\map_keys(Iter\range(1, 10), fn (int $key): string => (string) $key), + Iter\map_keys(Iter\range(1, 10), static fn (int $key): string => (string) $key), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ]; yield [ - Iter\map(Iter\range(1, 10), fn (int $value): string => Str\format('00%d', $value)), + Iter\map(Iter\range(1, 10), static fn (int $value): string => Str\format('00%d', $value)), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ]; } diff --git a/tests/Psl/Type/BoolTypeTest.php b/tests/Psl/Type/BoolTypeTest.php index 3dae962b..9d4ef73b 100644 --- a/tests/Psl/Type/BoolTypeTest.php +++ b/tests/Psl/Type/BoolTypeTest.php @@ -6,7 +6,7 @@ use Psl\Type; -class BoolTypeTest extends TypeTest +final class BoolTypeTest extends TypeTest { public function getType(): Type\Type { diff --git a/tests/Psl/Type/Exception/TypeAssertExceptionTest.php b/tests/Psl/Type/Exception/TypeAssertExceptionTest.php index 275dcb4c..eb60e23d 100644 --- a/tests/Psl/Type/Exception/TypeAssertExceptionTest.php +++ b/tests/Psl/Type/Exception/TypeAssertExceptionTest.php @@ -10,7 +10,7 @@ use Psl\Str; use Psl\Type; -class TypeAssertExceptionTest extends TestCase +final class TypeAssertExceptionTest extends TestCase { public function testIncorrectIterableKey(): void { @@ -21,7 +21,7 @@ public function testIncorrectIterableKey(): void 'hello' => new Collection\Vector([1, 2, 3]) ]); - self::fail(Str\format('Expected "%s" exception to be thrown.', Type\Exception\AssertException::class)); + static::fail(Str\format('Expected "%s" exception to be thrown.', Type\Exception\AssertException::class)); } catch (Type\Exception\AssertException $e) { static::assertSame('int', $e->getExpectedType()); static::assertSame('string', $e->getActualType()); @@ -42,7 +42,7 @@ public function testIncorrectResourceType(): void try { $type->assert(STDIN); - self::fail(Str\format('Expected "%s" exception to be thrown.', Type\Exception\AssertException::class)); + static::fail(Str\format('Expected "%s" exception to be thrown.', Type\Exception\AssertException::class)); } catch (Type\Exception\AssertException $e) { static::assertSame('resource', $e->getExpectedType()); static::assertSame('resource', $e->getActualType()); diff --git a/tests/Psl/Type/Exception/TypeCoercionExceptionTest.php b/tests/Psl/Type/Exception/TypeCoercionExceptionTest.php index 709064e3..3d947b4f 100644 --- a/tests/Psl/Type/Exception/TypeCoercionExceptionTest.php +++ b/tests/Psl/Type/Exception/TypeCoercionExceptionTest.php @@ -10,7 +10,7 @@ use Psl\Str; use Psl\Type; -class TypeCoercionExceptionTest extends TestCase +final class TypeCoercionExceptionTest extends TestCase { public function testIncorrectIterableKey(): void { @@ -21,7 +21,7 @@ public function testIncorrectIterableKey(): void 4 => new Collection\Vector([1, 2, 3]) ]); - self::fail(Str\format( + static::fail(Str\format( 'Expected "%s" exception to be thrown.', Type\Exception\CoercionException::class )); @@ -45,7 +45,7 @@ public function testIncorrectResourceType(): void try { $type->coerce(new Collection\Map(['hello' => 'foo'])); - self::fail(Str\format( + static::fail(Str\format( 'Expected "%s" exception to be thrown.', Type\Exception\CoercionException::class )); diff --git a/tests/Psl/Type/FloatTypeTest.php b/tests/Psl/Type/FloatTypeTest.php index 8a87f7dc..39d90447 100644 --- a/tests/Psl/Type/FloatTypeTest.php +++ b/tests/Psl/Type/FloatTypeTest.php @@ -7,7 +7,7 @@ use Psl\Math; use Psl\Type; -class FloatTypeTest extends TypeTest +final class FloatTypeTest extends TypeTest { public function getType(): Type\Type { diff --git a/tests/Psl/Type/IntTypeTest.php b/tests/Psl/Type/IntTypeTest.php index 158ee652..ed0a29e8 100644 --- a/tests/Psl/Type/IntTypeTest.php +++ b/tests/Psl/Type/IntTypeTest.php @@ -7,7 +7,7 @@ use Psl\Math; use Psl\Type; -class IntTypeTest extends TypeTest +final class IntTypeTest extends TypeTest { public function getType(): Type\Type { diff --git a/tests/Psl/Type/IntersectionTypeTest.php b/tests/Psl/Type/IntersectionTypeTest.php index 533ea764..40b643dc 100644 --- a/tests/Psl/Type/IntersectionTypeTest.php +++ b/tests/Psl/Type/IntersectionTypeTest.php @@ -4,17 +4,18 @@ namespace Psl\Tests\Type; +use Iterator; use Psl\Collection\CollectionInterface; use Psl\Collection\IndexAccessInterface; use Psl\Type; -class IntersectionTypeTest extends TypeTest +final class IntersectionTypeTest extends TypeTest { public function testIntersectionLeft(): void { $intersection = Type\intersection(Type\array_key(), Type\int()); - self::assertSame(1, $intersection->coerce('1')); + static::assertSame(1, $intersection->coerce('1')); } public function getType(): Type\Type @@ -54,11 +55,11 @@ public function getToStringExamples(): iterable yield [Type\intersection( Type\object(IndexAccessInterface::class), - Type\union(Type\object(CollectionInterface::class), Type\object(\Iterator::class)) + Type\union(Type\object(CollectionInterface::class), Type\object(Iterator::class)) ), 'Psl\Collection\IndexAccessInterface&(Psl\Collection\CollectionInterface|Iterator)']; yield [Type\intersection( - Type\union(Type\object(CollectionInterface::class), Type\object(\Iterator::class)), + Type\union(Type\object(CollectionInterface::class), Type\object(Iterator::class)), Type\object(IndexAccessInterface::class) ), '(Psl\Collection\CollectionInterface|Iterator)&Psl\Collection\IndexAccessInterface']; } diff --git a/tests/Psl/Type/IsArrayTest.php b/tests/Psl/Type/IsArrayTest.php index 5c4f3102..76ffe8d7 100644 --- a/tests/Psl/Type/IsArrayTest.php +++ b/tests/Psl/Type/IsArrayTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Psl\Type; -class IsArrayTest extends TestCase +final class IsArrayTest extends TestCase { /** * @dataProvider provideData @@ -32,7 +32,7 @@ public function provideData(): array [ false, - (fn () => yield 5)(), + (static fn () => yield 5)(), ], [ diff --git a/tests/Psl/Type/IsArraykeyTest.php b/tests/Psl/Type/IsArraykeyTest.php index a9daa57b..c6c002c2 100644 --- a/tests/Psl/Type/IsArraykeyTest.php +++ b/tests/Psl/Type/IsArraykeyTest.php @@ -9,20 +9,20 @@ use Psl\Str; use Psl\Type; -class IsArraykeyTest extends TestCase +final class IsArraykeyTest extends TestCase { public function testIsArraykey(): void { - self::assertTrue(Type\is_arraykey('')); - self::assertTrue(Type\is_arraykey(Str\chr(0))); - self::assertTrue(Type\is_arraykey(123)); - self::assertTrue(Type\is_arraykey(0)); - self::assertTrue(Type\is_arraykey(Math\INT16_MAX)); + static::assertTrue(Type\is_arraykey('')); + static::assertTrue(Type\is_arraykey(Str\chr(0))); + static::assertTrue(Type\is_arraykey(123)); + static::assertTrue(Type\is_arraykey(0)); + static::assertTrue(Type\is_arraykey(Math\INT16_MAX)); - self::assertFalse(Type\is_arraykey(5.0)); - self::assertFalse(Type\is_arraykey(true)); - self::assertFalse(Type\is_arraykey(null)); - self::assertFalse(Type\is_arraykey( + static::assertFalse(Type\is_arraykey(5.0)); + static::assertFalse(Type\is_arraykey(true)); + static::assertFalse(Type\is_arraykey(null)); + static::assertFalse(Type\is_arraykey( new class { public function __toString(): string { diff --git a/tests/Psl/Type/IsCallableTest.php b/tests/Psl/Type/IsCallableTest.php index e62f9507..fc883782 100644 --- a/tests/Psl/Type/IsCallableTest.php +++ b/tests/Psl/Type/IsCallableTest.php @@ -5,22 +5,21 @@ namespace Psl\Tests\Type; use PHPUnit\Framework\TestCase; -use Psl\Iter; use Psl\Type; -class IsCallableTest extends TestCase +final class IsCallableTest extends TestCase { /** * @dataProvider provideData */ public function testIsCallable(bool $expected, $value): void { - self::assertSame($expected, Type\is_callable($value)); + static::assertSame($expected, Type\is_callable($value)); } public function provideData(): iterable { - yield [true, fn () => 'hello']; + yield [true, static fn () => 'hello']; yield [true, [$this, 'provideData']]; yield [true, 'Psl\Type\is_callable']; yield [false, [$this, 'non_existent_method']]; diff --git a/tests/Psl/Type/IsInstanceOfTest.php b/tests/Psl/Type/IsInstanceOfTest.php index 1fdcc5ca..1e4dc8c3 100644 --- a/tests/Psl/Type/IsInstanceOfTest.php +++ b/tests/Psl/Type/IsInstanceOfTest.php @@ -8,13 +8,13 @@ use Psl\Type; use stdClass; -class IsInstanceOfTest extends TestCase +final class IsInstanceOfTest extends TestCase { public function testIsInstanceOf(): void { - self::assertTrue(Type\is_instanceof(new stdClass(), stdClass::class)); - self::assertTrue(Type\is_instanceof($this, TestCase::class)); + static::assertTrue(Type\is_instanceof(new stdClass(), stdClass::class)); + static::assertTrue(Type\is_instanceof($this, TestCase::class)); - self::assertFalse(Type\is_instanceof(new stdClass(), TestCase::class)); + static::assertFalse(Type\is_instanceof(new stdClass(), TestCase::class)); } } diff --git a/tests/Psl/Type/IsIntTest.php b/tests/Psl/Type/IsIntTest.php index 9d41d0a1..3aa5098b 100644 --- a/tests/Psl/Type/IsIntTest.php +++ b/tests/Psl/Type/IsIntTest.php @@ -8,17 +8,17 @@ use Psl\Math; use Psl\Type; -class IsIntTest extends TestCase +final class IsIntTest extends TestCase { public function testIsInt(): void { - self::assertTrue(Type\is_int(123)); - self::assertTrue(Type\is_int(0)); - self::assertTrue(Type\is_int(Math\INT16_MAX)); + static::assertTrue(Type\is_int(123)); + static::assertTrue(Type\is_int(0)); + static::assertTrue(Type\is_int(Math\INT16_MAX)); - self::assertFalse(Type\is_int('5')); - self::assertFalse(Type\is_int(5.0)); - self::assertFalse(Type\is_int(true)); - self::assertFalse(Type\is_int(null)); + static::assertFalse(Type\is_int('5')); + static::assertFalse(Type\is_int(5.0)); + static::assertFalse(Type\is_int(true)); + static::assertFalse(Type\is_int(null)); } } diff --git a/tests/Psl/Type/IsIterableTest.php b/tests/Psl/Type/IsIterableTest.php index c1b9dfdd..7406ab07 100644 --- a/tests/Psl/Type/IsIterableTest.php +++ b/tests/Psl/Type/IsIterableTest.php @@ -8,14 +8,14 @@ use Psl\Iter; use Psl\Type; -class IsIterableTest extends TestCase +final class IsIterableTest extends TestCase { /** * @dataProvider provideIsIterableData */ public function testIsIterable($value, bool $expected): void { - self::assertSame($expected, Type\is_iterable($value)); + static::assertSame($expected, Type\is_iterable($value)); } public function provideIsIterableData(): iterable @@ -27,6 +27,6 @@ public function provideIsIterableData(): iterable yield [Iter\to_iterator([1, 2]), true]; yield [$this, false]; yield [STDIN, false]; - yield [(fn () => yield false)(), true]; + yield [(static fn () => yield false)(), true]; } } diff --git a/tests/Psl/Type/IsNaNTest.php b/tests/Psl/Type/IsNaNTest.php index dd93be31..5f1467cb 100644 --- a/tests/Psl/Type/IsNaNTest.php +++ b/tests/Psl/Type/IsNaNTest.php @@ -8,13 +8,13 @@ use Psl\Math; use Psl\Type; -class IsNaNTest extends TestCase +final class IsNaNTest extends TestCase { public function testIsNaN(): void { - self::assertTrue(Type\is_nan(Math\NAN)); + static::assertTrue(Type\is_nan(Math\NAN)); - self::assertFalse(Type\is_nan(Math\INFINITY)); - self::assertFalse(Type\is_nan(5.0)); + static::assertFalse(Type\is_nan(Math\INFINITY)); + static::assertFalse(Type\is_nan(5.0)); } } diff --git a/tests/Psl/Type/IsNumericTest.php b/tests/Psl/Type/IsNumericTest.php index 33ab2037..dc5a1a5f 100644 --- a/tests/Psl/Type/IsNumericTest.php +++ b/tests/Psl/Type/IsNumericTest.php @@ -7,21 +7,22 @@ use PHPUnit\Framework\TestCase; use Psl\Math; use Psl\Type; +use stdClass; -class IsNumericTest extends TestCase +final class IsNumericTest extends TestCase { public function testIsNumeric(): void { - self::assertTrue(Type\is_numeric(Math\NAN)); - self::assertTrue(Type\is_numeric(1)); - self::assertTrue(Type\is_numeric(1.0)); - self::assertTrue(Type\is_numeric('1')); - self::assertTrue(Type\is_numeric('1.0')); - self::assertTrue(Type\is_numeric(Math\INFINITY)); - self::assertTrue(Type\is_numeric(5.0)); + static::assertTrue(Type\is_numeric(Math\NAN)); + static::assertTrue(Type\is_numeric(1)); + static::assertTrue(Type\is_numeric(1.0)); + static::assertTrue(Type\is_numeric('1')); + static::assertTrue(Type\is_numeric('1.0')); + static::assertTrue(Type\is_numeric(Math\INFINITY)); + static::assertTrue(Type\is_numeric(5.0)); - self::assertFalse(Type\is_numeric([])); - self::assertFalse(Type\is_numeric(new \stdClass())); - self::assertFalse(Type\is_numeric('hello')); + static::assertFalse(Type\is_numeric([])); + static::assertFalse(Type\is_numeric(new stdClass())); + static::assertFalse(Type\is_numeric('hello')); } } diff --git a/tests/Psl/Type/IsScalarTest.php b/tests/Psl/Type/IsScalarTest.php index 86d9def8..e1b424de 100644 --- a/tests/Psl/Type/IsScalarTest.php +++ b/tests/Psl/Type/IsScalarTest.php @@ -9,21 +9,21 @@ use Psl\Str; use Psl\Type; -class IsScalarTest extends TestCase +final class IsScalarTest extends TestCase { public function testIsScalar(): void { - self::assertTrue(Type\is_scalar('')); - self::assertTrue(Type\is_scalar(Str\chr(0))); - self::assertTrue(Type\is_scalar(123)); - self::assertTrue(Type\is_scalar(0)); - self::assertTrue(Type\is_scalar(Math\INT16_MAX)); - self::assertTrue(Type\is_scalar(Math\INFINITY)); - self::assertTrue(Type\is_scalar(5.0)); - self::assertTrue(Type\is_scalar(true)); + static::assertTrue(Type\is_scalar('')); + static::assertTrue(Type\is_scalar(Str\chr(0))); + static::assertTrue(Type\is_scalar(123)); + static::assertTrue(Type\is_scalar(0)); + static::assertTrue(Type\is_scalar(Math\INT16_MAX)); + static::assertTrue(Type\is_scalar(Math\INFINITY)); + static::assertTrue(Type\is_scalar(5.0)); + static::assertTrue(Type\is_scalar(true)); - self::assertFalse(Type\is_scalar(null)); - self::assertFalse(Type\is_scalar( + static::assertFalse(Type\is_scalar(null)); + static::assertFalse(Type\is_scalar( new class { public function __toString(): string { diff --git a/tests/Psl/Type/IsStringTest.php b/tests/Psl/Type/IsStringTest.php index 1039ef7c..8dc957a1 100644 --- a/tests/Psl/Type/IsStringTest.php +++ b/tests/Psl/Type/IsStringTest.php @@ -8,18 +8,18 @@ use Psl\Str; use Psl\Type; -class IsStringTest extends TestCase +final class IsStringTest extends TestCase { public function testIsString(): void { - self::assertTrue(Type\is_string('')); - self::assertTrue(Type\is_string(Str\chr(0))); + static::assertTrue(Type\is_string('')); + static::assertTrue(Type\is_string(Str\chr(0))); - self::assertFalse(Type\is_string(5)); - self::assertFalse(Type\is_string(5.0)); - self::assertFalse(Type\is_string(true)); - self::assertFalse(Type\is_string(null)); - self::assertFalse(Type\is_string( + static::assertFalse(Type\is_string(5)); + static::assertFalse(Type\is_string(5.0)); + static::assertFalse(Type\is_string(true)); + static::assertFalse(Type\is_string(null)); + static::assertFalse(Type\is_string( new class { public function __toString(): string { diff --git a/tests/Psl/Type/IterableTypeTest.php b/tests/Psl/Type/IterableTypeTest.php index 060caa44..86035596 100644 --- a/tests/Psl/Type/IterableTypeTest.php +++ b/tests/Psl/Type/IterableTypeTest.php @@ -11,7 +11,7 @@ /** * @extends TypeTest> */ -class IterableTypeTest extends TypeTest +final class IterableTypeTest extends TypeTest { public function getType(): Type\Type { @@ -25,17 +25,17 @@ public function getValidCoercions(): iterable yield [Iter\range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]; yield [ - Iter\map(Iter\range(1, 10), fn (int $value): string => (string) $value), + Iter\map(Iter\range(1, 10), static fn (int $value): string => (string) $value), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ]; yield [ - Iter\map_keys(Iter\range(1, 10), fn (int $key): string => (string) $key), + Iter\map_keys(Iter\range(1, 10), static fn (int $key): string => (string) $key), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ]; yield [ - Iter\map(Iter\range(1, 10), fn (int $value): string => Str\format('00%d', $value)), + Iter\map(Iter\range(1, 10), static fn (int $value): string => Str\format('00%d', $value)), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ]; } @@ -65,7 +65,6 @@ public function getToStringExamples(): iterable /** * @param iterable $a * @param iterable $b - * @return bool */ protected function equals($a, $b): bool { diff --git a/tests/Psl/Type/MixedTypeTest.php b/tests/Psl/Type/MixedTypeTest.php index c44a3cc9..e4479cee 100644 --- a/tests/Psl/Type/MixedTypeTest.php +++ b/tests/Psl/Type/MixedTypeTest.php @@ -7,7 +7,7 @@ use Psl\Math; use Psl\Type; -class MixedTypeTest extends TypeTest +final class MixedTypeTest extends TypeTest { public function getType(): Type\Type { diff --git a/tests/Psl/Type/NullTypeTest.php b/tests/Psl/Type/NullTypeTest.php index af59241a..41b5ddf7 100644 --- a/tests/Psl/Type/NullTypeTest.php +++ b/tests/Psl/Type/NullTypeTest.php @@ -6,7 +6,7 @@ use Psl\Type; -class NullTypeTest extends TypeTest +final class NullTypeTest extends TypeTest { public function getType(): Type\Type { diff --git a/tests/Psl/Type/NullableTypeTest.php b/tests/Psl/Type/NullableTypeTest.php index dd387948..d640f570 100644 --- a/tests/Psl/Type/NullableTypeTest.php +++ b/tests/Psl/Type/NullableTypeTest.php @@ -6,7 +6,7 @@ use Psl\Type; -class NullableTypeTest extends TypeTest +final class NullableTypeTest extends TypeTest { public function getType(): Type\Type { diff --git a/tests/Psl/Type/NumTypeTest.php b/tests/Psl/Type/NumTypeTest.php index 859baed5..01f0ffb1 100644 --- a/tests/Psl/Type/NumTypeTest.php +++ b/tests/Psl/Type/NumTypeTest.php @@ -7,7 +7,7 @@ use Psl\Math; use Psl\Type; -class NumTypeTest extends TypeTest +final class NumTypeTest extends TypeTest { public function getType(): Type\Type { diff --git a/tests/Psl/Type/ObjectTypeTest.php b/tests/Psl/Type/ObjectTypeTest.php index d4d6e8b6..b0c70f89 100644 --- a/tests/Psl/Type/ObjectTypeTest.php +++ b/tests/Psl/Type/ObjectTypeTest.php @@ -8,7 +8,7 @@ use Psl\Collection\CollectionInterface; use Psl\Type; -class ObjectTypeTest extends TypeTest +final class ObjectTypeTest extends TypeTest { public function getType(): Type\Type { diff --git a/tests/Psl/Type/ResourceSpecTest.php b/tests/Psl/Type/ResourceSpecTest.php index 69638506..cc22f7fb 100644 --- a/tests/Psl/Type/ResourceSpecTest.php +++ b/tests/Psl/Type/ResourceSpecTest.php @@ -4,10 +4,9 @@ namespace Psl\Tests\Type; -use Psl\Math; use Psl\Type; -class ResourceSpecTest extends TypeTest +final class ResourceSpecTest extends TypeTest { public function getType(): Type\Type { @@ -49,9 +48,9 @@ public function testNoKind(): void $spec = Type\resource(); $value = $spec->assert(STDIN); - self::assertSame(STDIN, $value); + static::assertSame(STDIN, $value); $value = $spec->coerce(STDIN); - self::assertSame(STDIN, $value); + static::assertSame(STDIN, $value); } } diff --git a/tests/Psl/Type/ResourceTypeTest.php b/tests/Psl/Type/ResourceTypeTest.php index 6d0a9fb9..cd2fe631 100644 --- a/tests/Psl/Type/ResourceTypeTest.php +++ b/tests/Psl/Type/ResourceTypeTest.php @@ -7,7 +7,7 @@ use Psl\Math; use Psl\Type; -class ResourceTypeTest extends TypeTest +final class ResourceTypeTest extends TypeTest { public function getType(): Type\Type { @@ -55,7 +55,7 @@ public function getInvalidCoercions(): iterable }]; yield [STDIN]; yield [[]]; - yield [(fn () => yield 'hello')()]; + yield [(static fn () => yield 'hello')()]; } public function getToStringExamples(): iterable diff --git a/tests/Psl/Type/StringTypeTest.php b/tests/Psl/Type/StringTypeTest.php index d12ea9ae..36380cf4 100644 --- a/tests/Psl/Type/StringTypeTest.php +++ b/tests/Psl/Type/StringTypeTest.php @@ -6,7 +6,7 @@ use Psl\Type; -class StringTypeTest extends TypeTest +final class StringTypeTest extends TypeTest { public function getType(): Type\Type { diff --git a/tests/Psl/Type/TypeTest.php b/tests/Psl/Type/TypeTest.php index aff37f0d..15fb29b9 100644 --- a/tests/Psl/Type/TypeTest.php +++ b/tests/Psl/Type/TypeTest.php @@ -5,7 +5,6 @@ namespace Psl\Tests\Type; use PHPUnit\Framework\TestCase; -use Psl\Arr; use Psl\Iter; use Psl\Type\Exception\AssertException; use Psl\Type\Exception\CoercionException; @@ -43,7 +42,7 @@ abstract public function getToStringExamples(): iterable; public function getValidValues(): array { $non_unique = $this->getValidCoercions(); - $non_unique = Iter\map($non_unique, fn ($tuple) => $tuple[1]); + $non_unique = Iter\map($non_unique, static fn ($tuple) => $tuple[1]); $out = []; foreach ($non_unique as $v) { @@ -88,8 +87,8 @@ final public function testValidCoercion($value, $expected): void { $actual = $this->getType()->coerce($value); - self::assertTrue($this->equals($expected, $actual)); - self::assertTrue($this->equals($actual, $this->getType()->coerce($actual))); + static::assertTrue($this->equals($expected, $actual)); + static::assertTrue($this->equals($actual, $this->getType()->coerce($actual))); } /** @@ -109,7 +108,7 @@ final public function testValidAssertion($value): void { $out = $this->getType()->assert($value); - self::assertTrue($this->equals($out, $value)); + static::assertTrue($this->equals($out, $value)); } /** @@ -127,7 +126,7 @@ public function testInvalidAssertion($value): void */ final public function testToString(Type $ts, string $expected): void { - self::assertSame($expected, $ts->toString()); + static::assertSame($expected, $ts->toString()); } /** diff --git a/tests/Psl/Type/UnionTypeTest.php b/tests/Psl/Type/UnionTypeTest.php index c9bafc78..5219e8d3 100644 --- a/tests/Psl/Type/UnionTypeTest.php +++ b/tests/Psl/Type/UnionTypeTest.php @@ -8,7 +8,7 @@ use Psl\Collection\IndexAccessInterface; use Psl\Type; -class UnionTypeTest extends TypeTest +final class UnionTypeTest extends TypeTest { public function getType(): Type\Type {