403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/yandex.market/lib/reference/concerns/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/yandex.market/lib/reference/concerns/hasonce.php
<?php

namespace Yandex\Market\Reference\Concerns;

use Yandex\Market;

trait HasOnce
{
	private $onceMemoized = [];

	/**
	 * @template T
	 *
	 * @param string $name
	 * @param array|null $arguments
	 * @param (callable(): T)|null $callable
	 *
	 * @return T
	 */
	protected function once($name, $arguments = null, $callable = null)
	{
		if ($callable === null && is_callable($arguments))
		{
			$callable = $arguments;
			$arguments = null;
		}

		$hash = Market\Utils\Caller::getArgumentsHash($arguments);

		if (!isset($this->onceMemoized[$name])) { $this->onceMemoized[$name] = []; }

		if (!isset($this->onceMemoized[$name][$hash]) && !array_key_exists($hash, $this->onceMemoized[$name]))
		{
			$this->onceMemoized[$name][$hash] = $this->callOnce($name, $arguments, $callable);
		}

		return $this->onceMemoized[$name][$hash];
	}

    /**
     * @param string $name
     */
    protected function clearOnce($name)
    {
        if (isset($this->onceMemoized[$name]))
        {
            $this->onceMemoized[$name] = null;
        }
    }

	/**
	 * @template T
	 *
	 * @param string $name
	 * @param array|null $arguments
	 * @param (callable(): T)|null $callable
	 *
	 * @return T
	 * @noinspection VariableFunctionsUsageInspection
	 */
	private function callOnce($name, $arguments = null, $callable = null)
	{
		if ($arguments === null)
		{
			$result = $callable !== null
				? call_user_func($callable)
				: $this->{$name}();
		}
		else if (is_array($arguments))
		{
			$result = $callable !== null
				? call_user_func_array($callable, $arguments)
				: $this->{$name}(...$arguments);
		}
		else
		{
			$result = $callable !== null
				? call_user_func($callable, $arguments)
				: $this->{$name}($arguments);
		}

		return $result;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit