Hey i keep getting an syntax error in my code but i see absolutly nothing wrong, maybe a second set of eyes will help.
<?php
namespace SyzerPHP\Environment;
/**
* Config.
*/
class Config extends Environment
{
/**
* validate().
*
* Validate the config array.
*
* @param array $conf The config array.
*
* @throws DomainException If `$conf` argument is empty.
* @throws DomainException If `$conf` argument does not have a depth of 2.
* @throws UnexpectedValueException If a section is not the start of an array.
* @throws UnexpectedValueException If the section variable names are not capital letters.
* @throws LengthException If the section variable name and/or value is too long.
*
* @return void.
*/
public static function validate(array $conf): void
{
if (\empty($conf)) {
throw new Exception\DomainException('The config array is empty.');
}
if (\depth($conf) != 2) {
throw new Exception\DomainException(\sprintf(
'The config array does not have a depth of 2. Depth: `%s`.',
(string) \depth($conf)
));
}
foreach ($conf as $var => $val) {
if (!\is_array($val)) {
throw new Exception\UnexpectedValueException(\sprintf(
'The section is not the start of an array. Passed: `%s`.',
\e($var)
));
}
foreach ($val as $var2 => $val2) {
if (!\ctype_upper(\str_replace('_', '', $var2))) {
throw new Exception\UnexpectedValueException(\sprintf(
'The section variable name must all be caps. Passed: `%s`.',
\e($var2)
));
}
if (\strlen($var2) > 30 || \strlen($val2) > 250) {
throw new Exception\LengthException(sprintf(
'The `$var2` and/or `$val2` variable is too long. Passed: `$var2` = `%s` `$val2` = `%s`.',
(string) \strlen($var2),
(string) \strlen($val2)
));
}
}
}
self::clearConfig();
self::$conf = $conf;
}
}
The stack trace leads to this line if (\empty($conf)) {
. I see no errors with the code. The php engine is expecting an identifier. As far as i am concerned i am missing no brackets, parenthesis, or any other symbol. The \
at the beginning of a function is to prevent substitution attacks. Also keep in mind this is php 7.2
syntax. If i missed an error please any help would be awesome. Thanks in advance.