mirror of
https://github.com/standardebooks/web.git
synced 2025-07-19 12:54:48 -04:00
Add Composer autoloading functions and PHPStan for testing
This commit is contained in:
parent
e198c4db65
commit
f5d7d4e02a
1518 changed files with 169063 additions and 30 deletions
87
vendor/nette/di/src/DI/Config/Helpers.php
vendored
Normal file
87
vendor/nette/di/src/DI/Config/Helpers.php
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
|
||||
namespace Nette\DI\Config;
|
||||
|
||||
use Nette;
|
||||
|
||||
|
||||
/**
|
||||
* Configuration helpers.
|
||||
*/
|
||||
class Helpers
|
||||
{
|
||||
use Nette\StaticClass;
|
||||
|
||||
const
|
||||
EXTENDS_KEY = '_extends',
|
||||
OVERWRITE = true;
|
||||
|
||||
|
||||
/**
|
||||
* Merges configurations. Left has higher priority than right one.
|
||||
* @return array|string
|
||||
*/
|
||||
public static function merge($left, $right)
|
||||
{
|
||||
if (is_array($left) && is_array($right)) {
|
||||
foreach ($left as $key => $val) {
|
||||
if (is_int($key)) {
|
||||
$right[] = $val;
|
||||
} else {
|
||||
if (is_array($val) && isset($val[self::EXTENDS_KEY])) {
|
||||
if ($val[self::EXTENDS_KEY] === self::OVERWRITE) {
|
||||
unset($val[self::EXTENDS_KEY]);
|
||||
}
|
||||
} elseif (isset($right[$key])) {
|
||||
$val = static::merge($val, $right[$key]);
|
||||
}
|
||||
$right[$key] = $val;
|
||||
}
|
||||
}
|
||||
return $right;
|
||||
|
||||
} elseif ($left === null && is_array($right)) {
|
||||
return $right;
|
||||
|
||||
} else {
|
||||
return $left;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds out and removes information about the parent.
|
||||
* @return mixed
|
||||
*/
|
||||
public static function takeParent(&$data)
|
||||
{
|
||||
if (is_array($data) && isset($data[self::EXTENDS_KEY])) {
|
||||
$parent = $data[self::EXTENDS_KEY];
|
||||
unset($data[self::EXTENDS_KEY]);
|
||||
return $parent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function isOverwriting(&$data)
|
||||
{
|
||||
return is_array($data) && isset($data[self::EXTENDS_KEY]) && $data[self::EXTENDS_KEY] === self::OVERWRITE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function isInheriting(&$data)
|
||||
{
|
||||
return is_array($data) && isset($data[self::EXTENDS_KEY]) && $data[self::EXTENDS_KEY] !== self::OVERWRITE;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue