Skip to content

Commit

Permalink
10.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Apr 7, 2024
1 parent 39028b3 commit 575ec92
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 34 deletions.
58 changes: 32 additions & 26 deletions Core/lib/array/sort.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,57 @@ function df_ksort_r_ci(array $a):array {return array_is_list($a)
* http://stackoverflow.com/questions/3235387
* https://bugs.php.net/bug.php?id=50688
* По этой причине добавил собаку.
* 2022-11-30
* «Deprecated Functionality: Collator::__construct():
* Passing null to parameter #1 ($locale) of type string is deprecated
* in vendor/justuno.com/core/lib/Core/array/sort.php on line 102»:
* https://github.com/justuno-com/core/issues/379
* 2024-04-08
* 1) From now on, it is locale-aware (previously, I had a separate locale-aware df_sort_l() / df_sort_names() function).
* 2) $isGet = true in:
* @used-by df_oqi_leafs()
* @used-by dfe_portal_stripe_customers()
* @used-by \Dfe\Oro\Test\Basic::t02_orders_stripe()
* 3) $l is used in:
* @used-by df_oqi_leafs()
* @used-by \Df\Directory\Model\ResourceModel\Country\Collection::mapFromCodeToName()
* @see df_ksort()
* @used-by df_countries_options()
* @used-by df_json_sort()
* @used-by df_modules_p()
* @used-by df_oqi_leafs()
* @used-by df_sort_l()
* @used-by df_zf_http_last_req()
* @used-by dfe_portal_stripe_customers()
* @used-by \Df\Config\Backend\ArrayT::processI()
* @used-by \Df\Directory\Model\ResourceModel\Country\Collection::mapFromCodeToName()
* @used-by \Df\Framework\Plugin\Css\PreProcessor\File\FileList\Collator::afterCollate()
* @used-by \Df\Payment\Info\Report::sort()
* @used-by \Df\Payment\TM::tResponses()
* @used-by \Dfe\Color\Image::probabilities()
* @used-by \Dfe\Oro\Test\Basic::t02_orders_stripe()
* @used-by \Dfe\Robokassa\Api\Options::p()
* @used-by \Dfe\YandexKassa\Source\Option::map()
* @used-by \Sharapov\Cabinetsbay\Block\Category\View::images() (https://github.com/cabinetsbay/site/issues/98)
* @used-by \Wolf\Filter\Block\Navigation::hDropdowns()
* @used-by \Wolf\Filter\Controller\Index\Change::execute()
* @param array(int|string => mixed) $a
* @param Closure|string|null $f [optional]
* @return array(int|string => mixed)
*/
function df_sort(array $a, $f = null):array {
function df_sort(array $a, $f = null, bool $isGet = false, string $l = ''):array {
# 2017-02-02 http://stackoverflow.com/a/7930575
$c = new Collator($l); /** @var Collator $c */
$isList = array_is_list($a); /** @var bool $isList */
if (!$f) {
$isList ? sort($a) : asort($a);
$isList ? $c->sort($a) : $c->asort($a);
}
else {
if (!$f instanceof Closure) {
$f = function($a, $b) use($f) {return !is_object($a) ? $a - $b : $a->$f() - $b->$f();};
if ($isGet) {
$f = function($a, $b) use($c, $f):int {return $c->compare(!$f ? $a : $f($a), !$f ? $b : $f($b));};
}
elseif (!$f instanceof Closure) {
$f = function($a, $b) use($f):int {return !is_object($a) ? $a - $b : $a->$f() - $b->$f();};
}
/** @noinspection PhpUsageOfSilenceOperatorInspection */
$isList ? @usort($a, $f) : @uasort($a, $f);
Expand All @@ -120,25 +147,4 @@ function df_sort(array $a, $f = null):array {
* @param array(int|string => mixed) $a
* @return array(int|string => mixed)
*/
function df_sort_a(array $a):array {asort($a); return $a;}

/**
* 2017-02-02 http://stackoverflow.com/a/7930575
* 2022-11-30
* «Deprecated Functionality: Collator::__construct():
* Passing null to parameter #1 ($locale) of type string is deprecated
* in vendor/justuno.com/core/lib/Core/array/sort.php on line 102»:
* https://github.com/justuno-com/core/issues/379
* @used-by df_countries_options()
* @used-by df_modules_p()
* @used-by df_oqi_leafs()
* @used-by df_zf_http_last_req()
* @used-by dfe_portal_stripe_customers()
* @used-by \Df\Directory\Model\ResourceModel\Country\Collection::mapFromCodeToName()
* @used-by \Dfe\Oro\Test\Basic::t02_orders_stripe()
* @used-by \Dfe\YandexKassa\Source\Option::map()
*/
function df_sort_l(array $a, string $l = '', callable $get = null):array {
$c = new Collator($l); /** @var Collator $c */
return df_sort($a, function($a, $b) use($c, $get) {return $c->compare(!$get ? $a : $get($a), !$get ? $b : $get($b));});
}
function df_sort_a(array $a):array {asort($a); return $a;}
4 changes: 2 additions & 2 deletions Directory/Model/ResourceModel/Country/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ final function mapFrom3To2():array {return dfc($this, function() {return df_map_
final function mapFromCodeToName(string $l = ''):array {return dfc($this, function($l) {
$needTranslate = 'en_US' !== $l; /** @var bool $needTranslate */
$zL = new zL($l); /** @var zL $zL */
return df_sort_l(df_map_r($this, function(C $c) use($needTranslate, $zL) {return [
return df_sort(df_map_r($this, function(C $c) use($needTranslate, $zL) {return [
$iso2 = $c->getId() /** @var string $iso2 */
,!$needTranslate ? $c->getName() : (zL::getTranslation($iso2, 'country', $zL) ?: $c->getName())];
}), $l);
}), null, false, $l);
}, [df_locale($l)]);}

/**
Expand Down
2 changes: 1 addition & 1 deletion Directory/lib/country.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function df_countries_ctn(string $locale = ''):array {return df_countries()->map
* @return array(array(string => string))
*/
function df_countries_options(array $filter = []):array {return dfcf(function(array $filter = []) {return df_map_to_options(
df_sort_l(dfa(df_countries_ctn(), df_etn($filter)))
df_sort(dfa(df_countries_ctn(), df_etn($filter)))
);}, func_get_args());}

/**
Expand Down
2 changes: 1 addition & 1 deletion Framework/lib/module/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ function df_module_m():MM {return df_o(MM::class);}
* @used-by dfe_modules()
* @return string[]
*/
function df_modules_p(string $p):array {return dfcf(function($p) {return df_sort_l(array_filter(
function df_modules_p(string $p):array {return dfcf(function($p) {return df_sort(array_filter(
df_module_list()->getNames(), function(string $m) use($p):bool {return df_starts_with($m, $p);}
));}, [$p]);}
4 changes: 2 additions & 2 deletions OQ/lib/oqi.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ function df_oqi_image($i):string {return df_product_image_url($i->getProduct());
* @return array(int => mixed)|OI[]|QI[]
*/
function df_oqi_leafs($oq, Closure $f = null, string $l = ''):array {
$r = df_sort_l(array_values(array_filter(
$r = df_sort(array_values(array_filter(
$oq->getItems(), function($i) {/** @var OI|QI $i */ return df_oqi_is_leaf($i);}
)), $l, function($i) {/** @var OI|QI $i */ return $i->getName();}); /** @var OI[]|QI[] $r */
)), function($i) {/** @var OI|QI $i */ return $i->getName();}, true, $l); /** @var OI[]|QI[] $r */
/**
* 2020-02-04
* If we got here from the `sales_order_place_after` event, then the order is not yet saved,
Expand Down
2 changes: 1 addition & 1 deletion Zf/lib/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function df_zf_http_last_req(C $c):string {
$s = "$b <...>";
}
return $s;
}, df_sort_l(df_tail($a)))), df_tail($sA));
}, df_sort(df_tail($a)))), df_tail($sA));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mage2pro/core"
,"version": "10.8.2"
,"version": "10.8.3"
,"description": "Mage2.PRO core package."
,"type": "magento2-module"
,"homepage": "https://mage2.pro"
Expand Down

0 comments on commit 575ec92

Please sign in to comment.