Skip to content

Commit a662c1e

Browse files
1 parent a14db02 commit a662c1e

File tree

39 files changed

+485
-275
lines changed

39 files changed

+485
-275
lines changed

Config/Settings.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ final function scope($s = null) {return !is_null($s) ? $s : $this->scopeDefault(
178178
* @used-by \Df\Payment\ConfigProvider::configOptions()
179179
* @used-by \Df\Payment\Init\Action::preconfigured()
180180
* @used-by \Df\Payment\Method::s()
181-
* @used-by \Df\Payment\Settings::currency()
182181
* @used-by \Df\Payment\Settings::description()
183182
* @used-by \Df\Payment\Settings::messageFailure()
184183
* @used-by \Df\Payment\Settings::probablyTestable()

Core/lib/array.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,12 @@ function df_filter($a, $b) {return array_filter(...(
252252
/**
253253
* 2016-10-25 Оказалось, что в ядре нет такой функции.
254254
* @used-by df_handle_prefix()
255+
* @used-by df_sales_email_sending()
255256
* @used-by \Df\Framework\Plugin\View\Layout::afterIsCacheable()
256257
* @used-by \Df\Payment\Info\Report::addAfter()
257258
* @used-by \Df\Payment\Method::amountFactor()
258-
* @used-by \Df\Payment\this()
259+
* @used-by \Df\Payment\TM::confirmed()
260+
* @used-by \Dfe\Stripe\Method::cardType()
259261
* @param callable|array(int|string => mixed)|array[]|mixed|\Traversable $a1
260262
* @param callable|array(int|string => mixed)|array[]|mixed|\Traversable $a2
261263
* @param mixed|mixed[] $pAppend [optional]
@@ -285,10 +287,8 @@ function df_find($a1, $a2, $pAppend = [], $pPrepend = [], $keyPosition = 0) {
285287
default:
286288
$primaryArgument = [$item];
287289
}
288-
$arguments = array_merge($pPrepend, $primaryArgument, $pAppend); /** @var mixed[] $arguments */
289-
$partialResult = call_user_func_array($callback, $arguments); /** @var mixed $partialResult */
290-
if (false !== $partialResult) {
291-
$result = $partialResult;
290+
if ($r = call_user_func_array($callback, array_merge($pPrepend, $primaryArgument, $pAppend))) {
291+
$result = !is_bool($r) ? $r : $item;
292292
break;
293293
}
294294
}

Core/lib/cache.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ function dfc($o, \Closure $m, array $a = [], $unique = true, $offset = 0) {
244244
* The usages with 5 arguments:
245245
* @used-by dfak()
246246
* @used-by \Df\OAuth\App::state()
247+
* @used-by \Df\Payment\Url::f()
247248
*
248249
* @return mixed
249250
*/

Core/lib/caller.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ function df_caller_f($offset = 0) {
6767
/**
6868
* 2016-09-06
6969
* Порой бывают случаи, когда @see df_caller_f() ошибочно вызывается из @see \Closure.
70-
* @see \Df\Payment\Settings::currency()
7170
* Добавил защиту от таких случаев.
7271
*/
7372
if (df_contains($result, '{closure}')) {

Core/lib/handle.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ function df_handle($name) {return in_array($name, df_handles());}
1515
* @param string $p
1616
* @return bool
1717
*/
18-
function df_handle_prefix($p) {return df_find(function($handle) use($p) {return
19-
df_starts_with($handle, $p);
20-
}, df_handles());}
18+
function df_handle_prefix($p) {return !!df_find(function($handle) use($p) {return
19+
df_starts_with($handle, $p)
20+
;}, df_handles());}
2121

2222
/**
2323
* 2015-12-21

Core/lib/objects.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ function df_idn($o, $allowNull = false) {return df_nat(df_id($o, $allowNull), $a
7676
* http://stackoverflow.com/a/25781989
7777
* http://php.net/manual/en/functions.arguments.php#example-145
7878
* @used-by \Df\API\Facade::p()
79+
* @used-by \Df\Payment\Currency::f()
7980
* @param string $c
8081
* @param array ...$args
8182
* @return object
@@ -176,7 +177,7 @@ function dfo($object, $key, $default = null) {return
176177
* 2017-07-11
177178
* It returns a singleton of a class from the $caller module with the $owner or $suf suffix.
178179
* The result should be a descendant of the $owner, and should exist (it is not defaulted to $owner).
179-
* @used-by \Df\OAuth\App::s()
180+
* @used-by df_oauth_app()
180181
* @used-by \Df\Zoho\App::s()
181182
* @used-by \Df\ZohoBI\API\Facade::s()
182183
* @param string|object $caller

Core/lib/reflection.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ function($c, $suf) {return
258258
* Отныне функция позволяет в качестве $def передавать интерфейс: @see df_class_suffix()
259259
*
260260
* @used-by \Df\API\Facade::p()
261-
* @used-by \Df\Sso\Button::s()
261+
* @used-by \Df\Sso\Button::s()
262+
* @used-by \Df\Payment\Currency::f()
262263
* @param object|string $c
263264
* @param string $def
264265
* @return string|null
@@ -274,12 +275,12 @@ function df_con_heir($c, $def) {return df_ar(
274275
* и так до тех пор, пока не найдёт в папке предка класс с суффиксом, как у $ar.
275276
* 2017-02-11 Отныне функция позволяет в качестве $ar передавать интерфейс: @see df_class_suffix()
276277
* @used-by \Df\Config\Settings::convention()
277-
* @used-by \Df\Payment\Choice::factory()
278+
* @used-by \Df\Payment\Choice::f()
278279
* @used-by \Df\Payment\Init\Action::p()
279280
* @used-by \Df\Payment\Method::getFormBlockType()
280281
* @used-by \Df\Payment\Method::getInfoBlockType()
281282
* @used-by \Df\Payment\Method::s()
282-
* @used-by \Df\Payment\Url::s()
283+
* @used-by \Df\Payment\Url::f()
283284
* @used-by \Df\Payment\W\F::__construct()
284285
* @used-by \Df\Payment\W\F::s()
285286
* @param object|string $c

Core/lib/validation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function df_abstract($caller) {
5252

5353
/**
5454
* 2016-11-10
55-
* @used-by \Df\Payment\Choice::factory()
55+
* @used-by \Df\Payment\Choice::f()
5656
* @param string|object $v
5757
* @param string|object|null $c [optional]
5858
* @param string|\Exception|null $m [optional]

Directory/FormElement/Currency.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22
namespace Df\Directory\FormElement;
3-
use Magento\Directory\Model\Currency as CurrencyM;
43
use Magento\Framework\App\ScopeInterface as S;
54
use Magento\Store\Model\Store;
65
// 2016-09-03
6+
/** @final Unable to use the PHP «final» keyword here because of the M2 code generation. */
77
class Currency extends Dropdown {
88
/**
99
* 2016-09-04
@@ -73,26 +73,27 @@ function getValues() {return dfc($this, function() {$v = $this->dfValues(); retu
7373
* 2016-09-05
7474
* Текущая валюта может меняться динамически (в том числе посетителем магазина и сессией),
7575
* поэтому мы используем параметр $store, а не $scope
76+
* @used-by \Df\Payment\Currency::iso3()
7677
* @param string $code
7778
* @param null|string|int|S|Store $store [optional]
78-
* @param CurrencyM|string|null $orderCurrency [optional]
79-
* @return CurrencyM
79+
* @param string|null $orderCurrency [optional]
80+
* @return string
8081
*/
81-
static function v($code, $store = null, $orderCurrency = null) {return df_currency(dftr(
82+
final static function v($code, $store = null, $orderCurrency = null) {return dftr(
8283
$code ?: self::$ORDER, self::map($store, $orderCurrency)
83-
));}
84+
);}
8485

8586
/**
8687
* 2016-09-05
8788
* @used-by v()
8889
* @param null|string|int|S|Store $store [optional]
89-
* @param CurrencyM|string|null $orderCurrency [optional]
90-
* @return array(string => CurrencyM|string|null)
90+
* @param string|null $orderCurrency [optional]
91+
* @return array(string => string|null)
9192
*/
9293
private static function map($store = null, $orderCurrency = null) {return dfcf(
9394
function($store = null, $orderCurrency = null) {return [
94-
self::$BASE => df_currency_base($store)
95-
,self::$ORDER => $orderCurrency ?: df_currency_current($store)
95+
self::$BASE => df_currency_base_c($store)
96+
,self::$ORDER => $orderCurrency ?: df_currency_current_c($store)
9697
];}
9798
, func_get_args());}
9899

Directory/lib/currency.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ function df_currency($c = null) {
9292
* Добавил возможность передачи в качестве $scope массива из 2-х элементов: [Scope Type, Scope Code].
9393
* Это стало ответом на удаление из ядра класса \Magento\Framework\App\Config\ScopePool
9494
* в Magento CE 2.1.3: https://github.com/magento/magento2/commit/3660d012
95-
*
95+
* @used-by \Df\Payment\Currency::rateToPayment()
96+
* @used-by \Df\Payment\Currency::toBase()
9697
* @param null|string|int|ScopeA|Store|ConfigData|IConfigData|O|Q|array(int|string) $s [optional]
9798
* @return C
9899
*/
@@ -102,6 +103,8 @@ function df_currency_base($s = null) {return df_currency(df_assert_sne(df_cfg(
102103

103104
/**
104105
* 2016-09-05
106+
* @used-by \Df\Directory\FormElement\Currency::map()
107+
* @used-by \Df\Payment\Currency::fromBase()
105108
* @param null|string|int|ScopeA|Store|ConfigData|IConfigData $s [optional]
106109
* @return string
107110
*/
@@ -143,6 +146,8 @@ function df_currency_code($c = null) {return df_currency($c)->getCode();}
143146
* @uses \Magento\Directory\Model\Currency::convert() прекрасно понимает нулевой $to:
144147
* https://github.com/magento/magento2/blob/2.1.1/app/code/Magento/Directory/Model/Currency.php#L216-L217
145148
*
149+
* @used-by \Df\Payment\Currency::toBase()
150+
* @used-by \Df\Payment\Currency::toOrder()
146151
* @param float $a
147152
* @param C|string|null $from [optional]
148153
* @param C|string|null $to [optional]
@@ -203,6 +208,7 @@ function df_currency_current($s = null) {return df_store($s)->getCurrentCurrency
203208
* В отличие от @see df_currency_base_с() здесь мы вынуждены использовать не $scope, а $store,
204209
* потому что учётную валюту можно просто считать из настроек,
205210
* а текущая валюта может меняться динамически (в том числе посетителем магазина и сессией).
211+
* @used-by \Df\Directory\FormElement\Currency::map()
206212
* @param int|string|null|bool|StoreInterface $s [optional]
207213
* @return string
208214
*/
@@ -221,6 +227,7 @@ function df_currency_has_rate($iso3, $s = null) {return !!dfa(df_currencies_ctn(
221227
/**
222228
* 2016-06-30
223229
* «How to programmatically get a currency's name by its ISO code?» https://mage2.pro/t/1833
230+
* @used-by \Df\Payment\ConfigProvider::config()
224231
* @param string|C|string[]|C[]|null $c [optional]
225232
* @return string|string[]
226233
*/

0 commit comments

Comments
 (0)