mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 17:41:50 +01:00
Fix "Found a contradiction when evaluating $fullBundleName and trying to reconcile type 'string' to !string" bug pointed by Psalm
This commit is contained in:
@@ -61,14 +61,10 @@ class Bundle
|
|||||||
* @throws IncorrectBundleNameException
|
* @throws IncorrectBundleNameException
|
||||||
* @return null|string
|
* @return null|string
|
||||||
*/
|
*/
|
||||||
public static function getShortBundleName($fullBundleName)
|
public static function getShortBundleName(string $fullBundleName): ?string
|
||||||
{
|
{
|
||||||
// Oops, given name of bundle is invalid
|
// Oops, given name of bundle is invalid
|
||||||
if (!Regex::isValidBundleName($fullBundleName)) {
|
if (!Regex::isValidBundleName($fullBundleName)) {
|
||||||
if (!is_string($fullBundleName)) {
|
|
||||||
$fullBundleName = gettype($fullBundleName);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new IncorrectBundleNameException($fullBundleName);
|
throw new IncorrectBundleNameException($fullBundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,16 +85,10 @@ class BundleTest extends BaseTestCase
|
|||||||
self::assertEquals($expected, Bundle::getBundleViewPath($viewPath, $bundleName, $extension));
|
self::assertEquals($expected, Bundle::getBundleViewPath($viewPath, $bundleName, $extension));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function testGetShortBundleNameUsingEmptyValue(): void
|
||||||
* @param mixed $emptyValue Empty value, e.g. ""
|
|
||||||
*
|
|
||||||
* @throws IncorrectBundleNameException
|
|
||||||
* @dataProvider provideEmptyValue
|
|
||||||
*/
|
|
||||||
public function testGetShortBundleNameUsingEmptyValue($emptyValue)
|
|
||||||
{
|
{
|
||||||
$this->expectException(IncorrectBundleNameException::class);
|
$this->expectException(IncorrectBundleNameException::class);
|
||||||
Bundle::getShortBundleName($emptyValue);
|
Bundle::getShortBundleName('');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user