Skip to content
Closed
Changes from 3 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
22 changes: 16 additions & 6 deletions src/Illuminate/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public static function ascii($value, $language = 'en')
{
$languageSpecific = static::languageSpecificCharsArray($language);

if (! is_null($languageSpecific)) {
Copy link
Author

Choose a reason for hiding this comment

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

https://github.com/kalessil/phpinspectionsea/blob/master/docs/probable-bugs.md#null-pointer-exceptions-prevention

is_object(), is_null() and similar is_*() functions calls are not analyzed, instead we recommend to rely on null identity and instanceof operators;

All 'is_null(...)' calls can be safely replaced with 'null === ...' constructs (or 'null !== ...' if the original construct was negated).

Copy link
Contributor

Choose a reason for hiding this comment

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

The rest of the framework uses is_null

Copy link
Author

Choose a reason for hiding this comment

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

@ntzm yes, but it will be more clear and correct to use null !== .... Should I revert this changes?

Copy link
Contributor

Choose a reason for hiding this comment

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

It should stay consistent throughout the framework

Copy link
Author

Choose a reason for hiding this comment

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

@ntzm Rolled back

$value = str_replace($languageSpecific[0], $languageSpecific[1], $value);
if ($languageSpecific !== null) {
$value = str_replace(array_keys($languageSpecific), array_values($languageSpecific), $value);
}

foreach (static::charsArray() as $key => $val) {
Expand Down Expand Up @@ -703,12 +703,22 @@ protected static function languageSpecificCharsArray($language)
if (! isset($languageSpecific)) {
$languageSpecific = [
'bg' => [
['х', 'Х', 'щ', 'Щ', 'ъ', 'Ъ', 'ь', 'Ь'],
['h', 'H', 'sht', 'SHT', 'a', 'А', 'y', 'Y'],
'х' => 'h',
'Х' => 'H',
'щ' => 'sht',
'Щ' => 'SHT',
'ъ' => 'a',
'Ъ' => 'А',
'ь' => 'y',
'Ь' => 'Y',
],
'de' => [
['ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü'],
['ae', 'oe', 'ue', 'AE', 'OE', 'UE'],
'ä' => 'ae',
'ö' => 'oe',
'ü' => 'ue',
'Ä' => 'AE',
'Ö' => 'OE',
'Ü' => 'UE',
],
];
}
Expand Down