| @@ -12,13 +12,13 @@ | ||
| 12 | 12 | namespace WindPress\WindPress\Utils; |
| 13 | 13 | |
| 14 | 14 | use ArrayAccess; |
| 15 | 15 | use Exception; |
| 16 | +use WindPressDeps\Symfony\Component\PropertyAccess\Exception\AccessException; | |
| 17 | +use WindPressDeps\Symfony\Component\PropertyAccess\Exception\InvalidArgumentException; | |
| 18 | +use WindPressDeps\Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException; | |
| 19 | +use WindPressDeps\Symfony\Component\PropertyAccess\PropertyAccess; | |
| 16 | 20 | use WIND_PRESS; |
| 17 | -use WindPressPackages\Symfony\Component\PropertyAccess\Exception\AccessException; | |
| 18 | -use WindPressPackages\Symfony\Component\PropertyAccess\Exception\InvalidArgumentException; | |
| 19 | -use WindPressPackages\Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException; | |
| 20 | -use WindPressPackages\Symfony\Component\PropertyAccess\PropertyAccess; | |
| 21 | 21 | /** |
| 22 | 22 | * Accessor for the plugin config. |
| 23 | 23 | * |
| 24 | 24 | * @since 3.0.0 |
| @@ -27,9 +27,9 @@ | ||
| 27 | 27 | { |
| 28 | 28 | /** |
| 29 | 29 | * Stores the instance of PropertyAccessor, implementing a Singleton pattern. |
| 30 | 30 | */ |
| 31 | - private static ?\WindPressPackages\Symfony\Component\PropertyAccess\PropertyAccessorInterface $propertyAccessor = null; | |
| 31 | + private static ?\WindPressDeps\Symfony\Component\PropertyAccess\PropertyAccessorInterface $propertyAccessor = null; | |
| 32 | 32 | public static function propertyAccessor() |
| 33 | 33 | { |
| 34 | 34 | if (!isset(self::$propertyAccessor)) { |
| 35 | 35 | self::$propertyAccessor = PropertyAccess::createPropertyAccessorBuilder()->enableExceptionOnInvalidIndex()->getPropertyAccessor(); |
| @@ -45,10 +45,10 @@ | ||
| 45 | 45 | * @return mixed The value at the end of the property path |
| 46 | 46 | */ |
| 47 | 47 | public static function get($path, $defaultValue = null) |
| 48 | 48 | { |
| 49 | - $options = \json_decode(\get_option(WIND_PRESS::WP_OPTION . '_options', '{}'), null, 512, \JSON_THROW_ON_ERROR); | |
| 50 | - $options = \apply_filters('f!windpress/utlis/config:options', $options); | |
| 49 | + $options = json_decode(get_option(WIND_PRESS::WP_OPTION . '_options', '{}'), null, 512, \JSON_THROW_ON_ERROR); | |
| 50 | + $options = apply_filters('f!windpress/utlis/config:options', $options); | |
| 51 | 51 | try { |
| 52 | 52 | return self::propertyAccessor()->getValue($options, $path); |
| 53 | 53 | } catch (Exception $exception) { |
| 54 | 54 | return $defaultValue; |
| @@ -65,16 +65,16 @@ | ||
| 65 | 65 | * @throws UnexpectedTypeException If a value within the path is neither object nor array |
| 66 | 66 | */ |
| 67 | 67 | public static function set($path, $value) |
| 68 | 68 | { |
| 69 | - $options = \json_decode(\get_option(WIND_PRESS::WP_OPTION . '_options', '{}'), null, 512, \JSON_THROW_ON_ERROR); | |
| 70 | - $options = \apply_filters('f!windpress/utlis/config:options', $options); | |
| 69 | + $options = json_decode(get_option(WIND_PRESS::WP_OPTION . '_options', '{}'), null, 512, \JSON_THROW_ON_ERROR); | |
| 70 | + $options = apply_filters('f!windpress/utlis/config:options', $options); | |
| 71 | 71 | if (self::propertyAccessor()->isWritable($options, $path)) { |
| 72 | 72 | self::propertyAccessor()->setValue($options, $path, $value); |
| 73 | 73 | } else { |
| 74 | 74 | self::data_set($options, $path, $value); |
| 75 | 75 | } |
| 76 | - \update_option(WIND_PRESS::WP_OPTION . '_options', \wp_json_encode($options, \JSON_THROW_ON_ERROR)); | |
| 76 | + update_option(WIND_PRESS::WP_OPTION . '_options', wp_json_encode($options, \JSON_THROW_ON_ERROR)); | |
| 77 | 77 | } |
| 78 | 78 | /** |
| 79 | 79 | * Set an item on an array or object using dot notation. |
| 80 | 80 | * |
| @@ -82,15 +82,15 @@ | ||
| 82 | 82 | * @param string|array $key |
| 83 | 83 | * @param mixed $value |
| 84 | 84 | * @param bool $overwrite |
| 85 | 85 | * @return mixed |
| 86 | - * | |
| 86 | + * | |
| 87 | 87 | * @see https://github.com/laravel/framework/blob/a84c4f41d3fb1c57684bb417b1f0858300e769d0/src/Illuminate/Collections/helpers.php#L109 |
| 88 | 88 | */ |
| 89 | 89 | public static function data_set(&$target, $key, $value, $overwrite = \true) |
| 90 | 90 | { |
| 91 | - $segments = \is_array($key) ? $key : \explode('.', $key); | |
| 92 | - if (($segment = \array_shift($segments)) === '*') { | |
| 91 | + $segments = is_array($key) ? $key : explode('.', $key); | |
| 92 | + if (($segment = array_shift($segments)) === '*') { | |
| 93 | 93 | if (!self::array_accessible($target)) { |
| 94 | 94 | $target = []; |
| 95 | 95 | } |
| 96 | 96 | if ($segments) { |
| @@ -110,9 +110,9 @@ | ||
| 110 | 110 | self::data_set($target[$segment], $segments, $value, $overwrite); |
| 111 | 111 | } elseif ($overwrite || !self::array_exists($target, $segment)) { |
| 112 | 112 | $target[$segment] = $value; |
| 113 | 113 | } |
| 114 | - } elseif (\is_object($target)) { | |
| 114 | + } elseif (is_object($target)) { | |
| 115 | 115 | if ($segments) { |
| 116 | 116 | if (!isset($target->{$segment})) { |
| 117 | 117 | $target->{$segment} = []; |
| 118 | 118 | } |
| @@ -135,9 +135,9 @@ | ||
| 135 | 135 | * |
| 136 | 136 | * @param \ArrayAccess|array $array |
| 137 | 137 | * @param string|int $key |
| 138 | 138 | * @return bool |
| 139 | - * | |
| 139 | + * | |
| 140 | 140 | * @see https://github.com/laravel/framework/blob/a84c4f41d3fb1c57684bb417b1f0858300e769d0/src/Illuminate/Collections/Arr.php#L164 |
| 141 | 141 | */ |
| 142 | 142 | public static function array_exists($array, $key) |
| 143 | 143 | { |
| @@ -143,12 +143,12 @@ | ||
| 143 | 143 | { |
| 144 | 144 | if ($array instanceof ArrayAccess) { |
| 145 | 145 | return $array->offsetExists($key); |
| 146 | 146 | } |
| 147 | - if (\is_float($key)) { | |
| 147 | + if (is_float($key)) { | |
| 148 | 148 | $key = (string) $key; |
| 149 | 149 | } |
| 150 | - return \array_key_exists($key, $array); | |
| 150 | + return array_key_exists($key, $array); | |
| 151 | 151 | } |
| 152 | 152 | /** |
| 153 | 153 | * Determine whether the given value is array accessible. |
| 154 | 154 | * |
| @@ -153,12 +153,12 @@ | ||
| 153 | 153 | * Determine whether the given value is array accessible. |
| 154 | 154 | * |
| 155 | 155 | * @param mixed $value |
| 156 | 156 | * @return bool |
| 157 | - * | |
| 157 | + * | |
| 158 | 158 | * @see https://github.com/laravel/framework/blob/a84c4f41d3fb1c57684bb417b1f0858300e769d0/src/Illuminate/Collections/Arr.php#L21 |
| 159 | 159 | */ |
| 160 | 160 | public static function array_accessible($value) |
| 161 | 161 | { |
| 162 | - return \is_array($value) || $value instanceof ArrayAccess; | |
| 162 | + return is_array($value) || $value instanceof ArrayAccess; | |
| 163 | 163 | } |
| 164 | 164 | } |