-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[6.x] Remove Container dependency on Illuminate\Support #30518
Merged
taylorotwell
merged 2 commits into
laravel:6.x
from
iansltx:remove-container-support-dep
Nov 6, 2019
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Illuminate\Container; | ||
|
||
class Util | ||
{ | ||
/** | ||
* If the given value is not an array and not null, wrap it in one. | ||
* | ||
* From Arr::wrap() in Illuminate\Support. | ||
* | ||
* @param mixed $value | ||
* @return array | ||
*/ | ||
public static function arrayWrap($value) | ||
{ | ||
if (is_null($value)) { | ||
return []; | ||
} | ||
|
||
return is_array($value) ? $value : [$value]; | ||
} | ||
|
||
/** | ||
* Return the default value of the given value. | ||
* | ||
* From global value() helper in Illuminate\Support. | ||
* | ||
* @param mixed $value | ||
* @return mixed | ||
*/ | ||
public static function unwrapIfClosure($value) | ||
{ | ||
return $value instanceof \Closure ? $value() : $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Container; | ||
|
||
use Illuminate\Container\Util; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class UtilTest extends TestCase | ||
{ | ||
public function testUnwrapIfClosure() | ||
{ | ||
$this->assertSame('foo', Util::unwrapIfClosure('foo')); | ||
$this->assertSame('foo', UtiL::unwrapIfClosure(function () { | ||
return 'foo'; | ||
})); | ||
} | ||
|
||
public function testArrayWrap() | ||
{ | ||
$string = 'a'; | ||
$array = ['a']; | ||
$object = new \stdClass; | ||
$object->value = 'a'; | ||
$this->assertEquals(['a'], Util::arrayWrap($string)); | ||
$this->assertEquals($array, Util::arrayWrap($array)); | ||
$this->assertEquals([$object], Util::arrayWrap($object)); | ||
$this->assertEquals([], Util::arrayWrap(null)); | ||
$this->assertEquals([null], Util::arrayWrap([null])); | ||
$this->assertEquals([null, null], Util::arrayWrap([null, null])); | ||
$this->assertEquals([''], Util::arrayWrap('')); | ||
$this->assertEquals([''], Util::arrayWrap([''])); | ||
$this->assertEquals([false], Util::arrayWrap(false)); | ||
$this->assertEquals([false], Util::arrayWrap([false])); | ||
$this->assertEquals([0], Util::arrayWrap(0)); | ||
|
||
$obj = new \stdClass; | ||
$obj->value = 'a'; | ||
$obj = unserialize(serialize($obj)); | ||
$this->assertEquals([$obj], Util::arrayWrap($obj)); | ||
$this->assertSame($obj, Util::arrayWrap($obj)[0]); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iansltx I noticed a capital
L
on this line.Actual:
UtiL::unwrapIfClosure
Expected:
Util::unwrapIfClosure
// @driesvints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops.
Mind PR'ing a typo fix here, as this has already been merged?