Check modifiers for right type and to have at least a visibility bit
enabled. Also turns null into private visibility.

@throws \InvalidArgumentException
@throws \DomainException

@param int|null $modifiers
779707
private function setModifiers(?int $modifiers): void
    {
        // Default to private.
        if ($modifiers === null) {
            $this->modifiers = \ReflectionProperty::IS_PRIVATE;

            return;
        }

        // Get the number of active visibility modifiers amount all modifies.
        $active_visibility_modifiers =
            ((bool) ($modifiers & \ReflectionProperty::IS_PRIVATE)) +
            ((bool) ($modifiers & \ReflectionProperty::IS_PROTECTED)) +
            ((bool) ($modifiers & \ReflectionProperty::IS_PUBLIC));

        // Not one and only one of private, protected and public is selected, throw exception.
        if ($active_visibility_modifiers !== 1) {
            throw new \DomainException(sprintf(
                '$modifiers (%s) has not ONE of IS_PRIVATE, IS_PROTECTED or IS_PUBLIC set, but found %s.',
                $modifiers,
                $active_visibility_modifiers
            ));
        }

        $this->modifiers = $modifiers;
    }
731931
public void addModifier(Modifier modifier) {
		if (modifier != null) {
			final String ruleName = modifier.getType();
			if (!Strings.isEmpty(ruleName)) {
				List<String> modifiers = this.modifiers.get(ruleName);
				if (modifiers == null) {
					modifiers = new ArrayList<>();
					this.modifiers.put(ruleName, modifiers);
				}
				modifiers.addAll(modifier.getModifiers());
			}
		}
	}
224777
private static boolean checkModifiers(Class<? extends AbstractPlugin> pluginClass) {
        int modifiers = pluginClass.getModifiers();
        return !Modifier.isAbstract(modifiers) &&
                !Modifier.isInterface(modifiers) &&
                !Modifier.isPrivate(modifiers);
    }
1176841
public function setFieldVisibility($visibility)
    {
        if ($visibility !== static::FIELD_VISIBLE_PRIVATE && $visibility !== static::FIELD_VISIBLE_PROTECTED) {
            throw new \InvalidArgumentException('Invalid provided visibility (only private and protected are allowed): ' . $visibility);
        }

        $this->fieldVisibility = $visibility;
    }
1350909
public void addModifier(String modifier) {
		if (!Strings.isEmpty(modifier)) {
			this.sarlInterface.getModifiers().add(modifier);
		}
	}
606997
protected function parseFieldModifiers(array $tokens)
	{
		$modifiers = MetaInfo::IS_PUBLIC;
		
		foreach($tokens as $tok)
		{
			if(is_array($tok))
			{
				switch($tok[0])
				{
					case T_VAR:
					case T_PUBLIC:
						$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PUBLIC;
						break;
					case T_PRIVATE:
						$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PRIVATE;
						break;
					case T_PROTECTED:
						$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PROTECTED;
						break;
					case T_STATIC:
						$modifiers |= MetaInfo::IS_STATIC;
						break;
				}
			}
		}
		
		return $modifiers;
	}
868317
private static function modifierArray($modifiers = []): array {
        if (is_string($modifiers)) {
            return [$modifiers];
        }
        $array = [];
        if (is_array($modifiers)) {
            foreach ($modifiers as $key => $value) {
                if (!$value) {
                    continue;
                }
                if (is_array($value)) {
                    $array = array_merge($array, self::modifierArray($value));
                } else if (is_string($value)) {
                    $array[] = $value;
                } else if (is_string($key)) {
                    $array[] = $key;
                }
            }
        }
        return array_unique($array);
    }
1264934
public void addModifier(String modifier) {
		if (!Strings.isEmpty(modifier)) {
			this.sarlEnumeration.getModifiers().add(modifier);
		}
	}
1319651
public function formatters($formatters = null)
    {
        if (!func_num_args()) {
            return $this->_formatters;
        }
        $this->_formatters = $formatters;
        return $this;
    }
527435
public function removeSelectModifier($modifier)
    {
        $this->selectModifiers = array_values(array_diff($this->selectModifiers, array($modifier)));

        return $this;
    }
1103245
private function parseModifiers($modifiers) {
		$info = new \n2n\log4php\formatting\FormattingInfo();
	
		// If no modifiers are given, return default values
		if (empty($modifiers)) {
			return $info;
		}
	
		// Validate
		$pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/';
		if (!preg_match($pattern, $modifiers)) {
			throw new \n2n\log4php\LoggerException("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING);
			return $info;
		}
	
		$parts = explode('.', $modifiers);
	
		if (!empty($parts[0])) {
			$minPart = (integer) $parts[0];
			$info->min = abs($minPart);
			$info->padLeft = ($minPart > 0);
		}
	
		if (!empty($parts[1])) {
			$maxPart = (integer) $parts[1];
			$info->max = abs($maxPart);
			$info->trimLeft = ($maxPart < 0);
		}
	
		return $info;
	}
655872
@Requires("modifier != null")
  @Ensures("getModifiers().contains(modifier)")
  public void addModifier(ElementModifier modifier) {
    switch (modifier) {
      case PRIVATE:
      case PACKAGE_PRIVATE:
      case PROTECTED:
      case PUBLIC:
        modifiers.remove(ElementModifier.PRIVATE);
        modifiers.remove(ElementModifier.PACKAGE_PRIVATE);
        modifiers.remove(ElementModifier.PROTECTED);
        modifiers.remove(ElementModifier.PUBLIC);
    }
    modifiers.add(modifier);
  }
20136
protected static function validateQueryData( array &$data, array $modifiers )
    {
        foreach( $data as $column => &$value ) {
            $value = $modifiers[$column]->exec( $value );
        }
    }
747176
function isModifierEnabled(modifiers, modifierName) {
  return modifiers.some(({ name, enabled }) => enabled && name === modifierName);
}
368584
protected List<Map<String, ?>> generateModifiers(Set<String> modifiers) {
		final List<Map<String, ?>> list = new ArrayList<>();
		if (!modifiers.isEmpty()) {
			list.add(pattern(it -> {
				it.matches(keywordRegex(modifiers));
				it.style(MODIFIER_STYLE);
				it.comment("Modifiers"); //$NON-NLS-1$
			}));
		}
		return list;
	}
1031718
public function modifyValues($modifiers, $subKey = null)
    {
        $process = function (&$source) use ($modifiers) {
            foreach ($modifiers as $key => $value) {
                if (is_callable($value)) {
                    $source[$key] = $value((isset($source[$key]) ? $source[$key] : null));
                } else {
                    $source[$key] = $value;
                }
            }
        };

        if (is_array($modifiers)) {

            if (is_null($subKey) || !isset($this->data[$subKey])) {
                $process($this->data);
            } else {

                $wrongSubKey = new \InvalidArgumentException(
                    sprintf("Wrong subKey given (%s), have no array value by this sub key", $subKey));;

                if (!is_array($this->data[$subKey])) {
                    throw $wrongSubKey;
                }

                array_map(function ($el) use ($wrongSubKey) {
                    if(!is_array($el)) throw $wrongSubKey;
                }, $this->data[$subKey]);

                foreach ($this->data[$subKey] as $key => $data) {
                    $process($this->data[$subKey][$key]);
                }
            }
        }

        return $this;
    }
1037110
protected function callModifiers(array $insertedPKs)
    {
        foreach ($this->modifiers as $modifier) {
            $modifier($this->model, $insertedPKs);
        }
    }