Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Removed unused mixins of Str #638

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/macros/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"friendsofhyperf/support": "~3.1.0",
"hyperf/collection": "~3.1.23",
"hyperf/macroable": "~3.1.0",
"hyperf/stringable": "~3.1.20",
"hyperf/stringable": "~3.1.23",
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Update hyperf/stringable version constraint to match other dependencies

The version constraints across Hyperf packages are inconsistent:

  • Most packages use ~3.1.0
  • hyperf/collection uses ~3.1.22
  • hyperf/stringable is being updated to ~3.1.23

To maintain consistency and prevent potential compatibility issues, consider:

  • Using ~3.1.0 for all Hyperf packages, or
  • Updating all packages to use the same minor version constraint
🔗 Analysis chain

Verify compatibility with other Hyperf dependencies

The version bump of hyperf/stringable to ~3.1.23 aligns with the removal of unused Str mixins. However, let's verify compatibility with other Hyperf packages that are also on ~3.1.0.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check version compatibility across Hyperf packages

# List all hyperf/* dependencies and their versions
rg '"hyperf/[^"]+": "~3\.1\.' composer.json

# Check if any package is potentially incompatible
if rg '"hyperf/[^"]+": "~3\.1\.([0-9]+)"' composer.json | awk -F'"' '{print $4}' | sort -u | wc -l | grep -q '^1$'; then
  echo "All Hyperf packages have consistent version constraints"
else
  echo "Warning: Inconsistent version constraints found"
fi

Length of output: 1998

"hyperf/support": "~3.1.0",
"nesbot/carbon": "^2.0|^3.0"
},
Expand All @@ -32,12 +32,12 @@
}
},
"suggest": {
"hyperf/http-server": "Required to use (~3.1.0)",
"league/commonmark": "Required to use (^1.3|^2.0.2)",
"opis/closure": "Required to use (^3.1)",
"ramsey/uuid": "Required to generate UUIDs (^4.7)",
"symfony/uid": "Required to generate ULIDs (^6.0|^7.0).",
"voku/portable-ascii": "Required to use (^1.4|^1.5)"
"hyperf/http-server": "Required to use RequestInterface.(~3.1.0)",
"league/commonmark": "Required to use markdown methods.(^1.3|^2.0.2)",
"opis/closure": "Required to use Closure.(^3.1)",
"ramsey/uuid": "Required to generate UUIDs.(^4.7)",
"symfony/uid": "Required to generate ULIDs.(^6.0|^7.0).",
"voku/portable-ascii": "Required to use ascii methods.(^1.4|^1.5)"
},
"extra": {
"hyperf": {
Expand Down
26 changes: 0 additions & 26 deletions src/macros/output/Hyperf/Stringable/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@

class Str
{
/**
* Set the callable that will be used to generate UUIDs.
*/
public static function createUuidsUsing(?callable $factory = null)
{
}

/**
* Indicate that UUIDs should be created normally and not using a custom factory.
*/
public static function createUuidsNormally()
{
}

/**
* Converts GitHub flavored Markdown into HTML.
*
Expand All @@ -46,16 +32,4 @@ public static function markdown($string, array $options = [])
public static function inlineMarkdown($string, array $options = [])
{
}

/**
* Transliterate a string to its closest ASCII representation.
*
* @param string $string
* @param string|null $unknown
* @param bool|null $strict
* @return string
*/
public static function transliterate($string, $unknown = '?', $strict = false)
{
}
}
17 changes: 0 additions & 17 deletions src/macros/src/StrMixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,18 @@

namespace FriendsOfHyperf\Macros;

use FriendsOfHyperf\Support\UuidContainer;
use Hyperf\Stringable\Str;
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\GithubFlavoredMarkdownExtension;
use League\CommonMark\Extension\InlinesOnly\InlinesOnlyExtension;
use League\CommonMark\GithubFlavoredMarkdownConverter;
use League\CommonMark\MarkdownConverter;
use voku\helper\ASCII;

/**
* @mixin Str
*/
class StrMixin
{
public function createUuidsNormally()
{
return fn () => UuidContainer::$uuidFactory = null;
}

public function createUuidsUsing()
{
return fn (?callable $factory = null) => UuidContainer::$uuidFactory = $factory;
}

public function inlineMarkdown()
{
return function ($string, array $options = []) {
Expand All @@ -53,9 +41,4 @@ public function markdown()
{
return fn ($string, array $options = []) => (string) (new GithubFlavoredMarkdownConverter($options))->convert($string);
}

public function transliterate()
{
return fn ($string, $unknown = '?', $strict = false) => ASCII::to_transliterate($string, $unknown, $strict);
}
}
17 changes: 0 additions & 17 deletions src/support/src/UuidContainer.php

This file was deleted.

34 changes: 0 additions & 34 deletions tests/Macros/StrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
*/
use Hyperf\Stringable\Str;

test('test isUuidWithValidUuid', function () {
$this->assertTrue(Str::isUuid(Str::uuid()->__toString()));
});

test('test isUuidWithInvalidUuid', function () {
$this->assertFalse(Str::isUuid('foo'));
});

test('test markdown', function ($expected, $value) {
expect(Str::markdown($value))->toBe($expected);
})->with([
Expand All @@ -31,29 +23,3 @@
["<em>hello world</em>\n", '*hello world*'],
["<a href=\"https://laravel.com\"><strong>Laravel</strong></a>\n", '[**Laravel**](https://laravel.com)'],
]);

test('test transliterate', function (string $value, string $expected) {
$this->assertSame($expected, Str::transliterate($value));
})->with('ialCharacterProvider');

dataset('ialCharacterProvider', [
['ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ', 'abcdefghijklmnopqrstuvwxyz'],
['⓪①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳', '01234567891011121314151617181920'],
['⓵⓶⓷⓸⓹⓺⓻⓼⓽⓾', '12345678910'],
['⓿⓫⓬⓭⓮⓯⓰⓱⓲⓳⓴', '011121314151617181920'],
['ⓣⓔⓢⓣ@ⓛⓐⓡⓐⓥⓔⓛ.ⓒⓞⓜ', '[email protected]'],
['🎂', '?'],
['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
['0123456789', '0123456789'],
]);

test('test transliterateOverrideUnknown', function ($args, $expected): void {
expect(Str::transliterate(...$args))->toBe($expected);
})->with([
[['🎂🚧🏆', 'H'], 'HHH'],
[['🎂', 'Hello'], 'Hello'],
]);

test('test transliterateStrict', function (string $value, string $expected): void {
$this->assertSame($expected, Str::transliterate($value, '?', true));
})->with('ialCharacterProvider');