-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #575 from jolicode/stub-sf-functions
Add official support strings and var-dumper functions
- Loading branch information
Showing
6 changed files
with
163 additions
and
1 deletion.
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,34 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\String { | ||
if (!\function_exists(\Symfony\Component\String\u::class)) { | ||
function u(?string $string = ''): \Symfony\Component\String\UnicodeString | ||
{ | ||
} | ||
} | ||
if (!\function_exists(\Symfony\Component\String\b::class)) { | ||
function b(?string $string = ''): \Symfony\Component\String\ByteString | ||
{ | ||
} | ||
} | ||
if (!\function_exists(\Symfony\Component\String\s::class)) { | ||
/** | ||
* @return \Symfony\Component\String\UnicodeString|\Symfony\Component\String\ByteString | ||
*/ | ||
function s(?string $string = ''): \Symfony\Component\String\AbstractString | ||
{ | ||
} | ||
} | ||
} | ||
namespace { | ||
if (!\function_exists('dump')) { | ||
function dump(mixed ...$vars): mixed | ||
{ | ||
} | ||
} | ||
if (!\function_exists('dd')) { | ||
function dd(mixed ...$vars): never | ||
{ | ||
} | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\String; | ||
|
||
if (!\function_exists(u::class)) { | ||
function u(?string $string = ''): UnicodeString | ||
{ | ||
return new UnicodeString($string ?? ''); | ||
} | ||
} | ||
|
||
if (!\function_exists(b::class)) { | ||
function b(?string $string = ''): ByteString | ||
{ | ||
return new ByteString($string ?? ''); | ||
} | ||
} | ||
|
||
if (!\function_exists(s::class)) { | ||
/** | ||
* @return UnicodeString|ByteString | ||
*/ | ||
function s(?string $string = ''): AbstractString | ||
{ | ||
$string ??= ''; | ||
|
||
return preg_match('//u', $string) ? new UnicodeString($string) : new ByteString($string); | ||
} | ||
} |
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,58 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Symfony\Component\VarDumper\Caster\ScalarStub; | ||
use Symfony\Component\VarDumper\VarDumper; | ||
|
||
if (!function_exists('dump')) { | ||
function dump(mixed ...$vars): mixed | ||
{ | ||
if (!$vars) { | ||
VarDumper::dump(new ScalarStub('🐛')); | ||
|
||
return null; | ||
} | ||
|
||
if (array_key_exists(0, $vars) && 1 === count($vars)) { | ||
VarDumper::dump($vars[0]); | ||
$k = 0; | ||
} else { | ||
foreach ($vars as $k => $v) { | ||
VarDumper::dump($v, is_int($k) ? 1 + $k : $k); | ||
} | ||
} | ||
|
||
if (1 < count($vars)) { | ||
return $vars; | ||
} | ||
|
||
return $vars[$k]; | ||
} | ||
} | ||
|
||
if (!function_exists('dd')) { | ||
function dd(mixed ...$vars): never | ||
{ | ||
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) && !headers_sent()) { | ||
header('HTTP/1.1 500 Internal Server Error'); | ||
} | ||
|
||
if (array_key_exists(0, $vars) && 1 === count($vars)) { | ||
VarDumper::dump($vars[0]); | ||
} else { | ||
foreach ($vars as $k => $v) { | ||
VarDumper::dump($v, is_int($k) ? 1 + $k : $k); | ||
} | ||
} | ||
|
||
exit(1); | ||
} | ||
} |