Skip to content

Commit

Permalink
https://github.com/mage2pro/core/issues/435
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Sep 21, 2024
1 parent eeb72b0 commit 5b763f2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
5 changes: 1 addition & 4 deletions Core/lib/lang/call/.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ function df_call($o, $f, array $p = []) {/** @var mixed $r */
# 2024-09-21
# 1) "`df_call()` should use `df_bool()` for `bool` arguments":
# https://github.com/mage2pro/core/issues/435
# 2) https://www.php.net/manual/en/reflectionparameter.gettype.php
# 3) https://www.php.net/manual/en/class.reflectionnamedtype.php
# 4) https://www.php.net/manual/en/reflectionnamedtype.getname.php#128874
if (($rt = $rp->getType()) instanceof RNT && 'bool' === $rt->getName()) {/** @var ?RT|?RNT $rt */
if (dfr_param_is_bool($rp)) {
$r = df_bool($r);
};
}
Expand Down
7 changes: 3 additions & 4 deletions Core/lib/reflection/param/is/bool.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php
use ReflectionNamedType as NT; # 2024-09-21 https://www.php.net/manual/en/class.reflectionnamedtype.php
use ReflectionParameter as P;
use ReflectionType as T; # 2024-09-21 https://www.php.net/manual/en/class.reflectiontype.php

/**
* 2024-09-21
* 2024-09-21 https://www.php.net/manual/en/reflectionnamedtype.getname.php#128874
* @used-by df_call()
*/
function dfr_param_is_bool(P $p):bool {return false;}
function dfr_param_is_bool(P $p):bool {return 'bool' === dfr_param_type($p);}
1 change: 1 addition & 0 deletions Core/lib/reflection/param/type.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
* https://www.php.net/manual/en/reflectionparameter.gettype.php
* https://www.php.net/manual/en/class.reflectionnamedtype.php
* https://www.php.net/manual/en/reflectionnamedtype.getname.php#128874
* @used-by dfr_param_is_bool()
*/
function dfr_param_type(P $p):string {return ($t = $p->getType()) instanceof NT ? $t->getName() : '';}

0 comments on commit 5b763f2

Please sign in to comment.