mirror of
https://github.com/rectorphp/rector.git
synced 2024-07-18 23:43:31 +00:00
[Strict] Skip possible result object or int on BooleanInIfConditionRuleFixerRector (#2016)
This commit is contained in:
parent
8f9abbd8b7
commit
4dd71f8f31
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* FUTURE NOTE: Dont add namespace to this Fixture:
|
||||
*
|
||||
* Skip Result Object or int only reproducible when on non-namespaced class
|
||||
* and collection of class is on single file
|
||||
*/
|
||||
class ForwardCompatibilityResult {
|
||||
|
||||
}
|
||||
|
||||
class QueryBuilder {
|
||||
/**
|
||||
* Executes this query using the bound parameters and their types.
|
||||
*
|
||||
* @return ForwardCompatibilityResult|int
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
if ($this->type === self::SELECT) {
|
||||
return new ForwardCompatibilityResult();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
class SkipResultObject
|
||||
{
|
||||
public function insert(): bool {
|
||||
$queryBuilder = new QueryBuilder();
|
||||
if ($queryBuilder->execute()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw new \RuntimeException('...');
|
||||
}
|
||||
}
|
|
@ -113,13 +113,17 @@ final class ExactCompareFactory
|
|||
$compareExprs[] = $this->createNotIdenticalFalsyCompare($unionedType, $expr, $treatAsNotEmpty);
|
||||
}
|
||||
|
||||
/** @var Expr $truthyExpr */
|
||||
/** @var ?Expr $truthyExpr */
|
||||
$truthyExpr = array_shift($compareExprs);
|
||||
foreach ($compareExprs as $compareExpr) {
|
||||
if (! $compareExpr instanceof Expr) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! $truthyExpr instanceof Expr) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @var Expr $compareExpr */
|
||||
$truthyExpr = new BooleanOr($truthyExpr, $compareExpr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user