Skip to content

Refactor TypeBuilder and resolve some todos #770

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

Merged
merged 5 commits into from
Nov 2, 2020
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
1 change: 1 addition & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ return PhpCsFixer\Config::create()
'phpdoc_to_comment' => false,
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
'global_namespace_import' => ['import_functions' => true, 'import_classes' => true, 'import_constants' => true],
'phpdoc_summary' => false,
]
)
->setFinder($finder)
Expand Down
9 changes: 7 additions & 2 deletions src/Error/InvalidArgumentError.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ class InvalidArgumentError extends GraphQLUserError
private string $name;
private ConstraintViolationListInterface $errors;

public function __construct(string $name, ConstraintViolationListInterface $errors, $message = '', $code = 0, Exception $previous = null)
{
public function __construct(
string $name,
ConstraintViolationListInterface $errors,
string $message = '',
int $code = 0,
Exception $previous = null
) {
$this->name = $name;
$this->errors = $errors;
parent::__construct($message, $code, $previous);
Expand Down
8 changes: 6 additions & 2 deletions src/Error/InvalidArgumentsError.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ class InvalidArgumentsError extends GraphQLUserError
/** @var InvalidArgumentError[] */
private array $errors;

public function __construct(array $errors, $message = '', $code = 0, Exception $previous = null)
{
public function __construct(
array $errors,
string $message = '',
int $code = 0,
Exception $previous = null
) {
$this->errors = $errors;
parent::__construct($message, $code, $previous);
}
Expand Down
8 changes: 6 additions & 2 deletions src/Error/UserErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ class UserErrors extends RuntimeException
/** @var UserError[] */
private array $errors = [];

public function __construct(array $errors, $message = '', $code = 0, Exception $previous = null)
{
public function __construct(
array $errors,
string $message = '',
int $code = 0,
Exception $previous = null
) {
$this->setErrors($errors);
parent::__construct($message, $code, $previous);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use function is_object;

/**
* @deprecated since 0.13 will be remove in 0.14
* @deprecated since 0.13 will be remove in 1.0
* @codeCoverageIgnore
*/
final class Helper
Expand Down
18 changes: 16 additions & 2 deletions src/ExpressionLanguage/ExpressionLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public function compile($expression, $names = [])
* Argument can be either an Expression object or a string with or
* without a prefix
*
* @param string $name - Name of the searched variable
* @param string|Expression $expression - Expression to search in
* @param string $name - name of the searched variable (needle)
* @param string|Expression $expression - expression to search in (haystack)
*
* @throws SyntaxError
*/
Expand Down Expand Up @@ -78,6 +78,20 @@ public static function expressionContainsVar(string $name, $expression): bool
return $contained ?? false;
}

/**
* Checks if value is a string and has the expression trigger prefix.
*
* @param mixed $value
*/
public static function isStringWithTrigger($value): bool
{
if (is_string($value)) {
return self::stringHasTrigger($value);
}

return false;
}

/**
* Checks if a string has the expression trigger prefix.
*/
Expand Down
7 changes: 1 addition & 6 deletions src/Generator/Converter/ExpressionConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Murtukov\PHPCodeGenerator\ConverterInterface;
use Overblog\GraphQLBundle\ExpressionLanguage\ExpressionLanguage;
use function is_string;

class ExpressionConverter implements ConverterInterface
{
Expand Down Expand Up @@ -35,10 +34,6 @@ public function convert($value)
*/
public function check($maybeExpression): bool
{
if (is_string($maybeExpression)) {
return ExpressionLanguage::stringHasTrigger($maybeExpression);
}

return false;
return ExpressionLanguage::isStringWithTrigger($maybeExpression);
}
}
Loading