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

build(deps): bump vimeo/psalm from 4.9.3 to 4.10.0 #14

Merged
merged 2 commits into from
Sep 12, 2021
Merged
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "BSD-3-Clause",
"require": {
"php": "^7.4 || ~8.0.0",
"vimeo/psalm": "^4.8",
"vimeo/psalm": "^4.10",
"webmozart/assert": "^1.10"
},
"require-dev": {
Expand Down
52 changes: 27 additions & 25 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Parser/PhpParser/StringableVariableInContextParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private function toString(Context $context): string
return LiteralIntVariableParser::stringify($variableName, $variable);
}

if (FloatVariableParser::isSingleFloatLiteral($variable)) {
if ($variable->isSingleFloatLiteral()) {
return FloatVariableParser::stringify($variable);
}

Expand Down
30 changes: 2 additions & 28 deletions src/Parser/Psalm/FloatVariableParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@

namespace Boesing\PsalmPluginStringf\Parser\Psalm;

use InvalidArgumentException;
use LogicException;
use Psalm\Type\Atomic\TFloat;
use Psalm\Type\Atomic\TLiteralFloat;
use Psalm\Type\Union;
use Webmozart\Assert\Assert;

use function assert;
use function count;
use function reset;

final class FloatVariableParser
{
Expand Down Expand Up @@ -46,8 +43,8 @@ private function toSingleFloat(): float

private function extract(Union $variableType): TFloat
{
if (self::isSingleFloatLiteral($variableType)) {
return self::getSingleFloatLiteral($variableType);
if ($variableType->isSingleFloatLiteral()) {
return $variableType->getSingleFloatLiteral();
}

$atomicTypes = $variableType->getAtomicTypes();
Expand All @@ -57,27 +54,4 @@ private function extract(Union $variableType): TFloat

return $type;
}

/**
* Can be removed when https://github.com/vimeo/psalm/pull/6252 will be merged.
*/
public static function isSingleFloatLiteral(Union $type): bool
{
return $type->getLiteralFloats() !== [] && $type->isSingle();
}

/**
* Can be removed when https://github.com/vimeo/psalm/pull/6252 will be merged.
*/
public static function getSingleFloatLiteral(Union $variableType): TLiteralFloat
{
if (! self::isSingleFloatLiteral($variableType)) {
throw new InvalidArgumentException('Not a single float literal');
}

$literals = $variableType->getLiteralFloats();
assert(count($literals) > 0);

return reset($literals);
}
}
2 changes: 1 addition & 1 deletion src/Parser/Psalm/TypeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function stringify(): ?string
}

if ($type->isFloat()) {
if (FloatVariableParser::isSingleFloatLiteral($type)) {
if ($type->isSingleFloatLiteral()) {
return FloatVariableParser::stringify($type);
}

Expand Down
1 change: 0 additions & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ private function registerExperimentalHooks(RegistrationInterface $registration,
}

foreach ($config->experimental->children() as $element) {
assert($element instanceof SimpleXMLElement);
$name = $element->getName();
if (! isset(self::EXPERIMENTAL_FEATURES[$name])) {
continue;
Expand Down