Source
* Returns a list of the unique hosts, used in a parsed trigger expression or empty array if expression is not valid
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/**
* Trigger expressions parser.
*/
class C10TriggerExpression {
// For parsing of trigger expression.
const STATE_AFTER_OPEN_BRACE = 1;
const STATE_AFTER_BINARY_OPERATOR = 2;
const STATE_AFTER_LOGICAL_OPERATOR = 3;
const STATE_AFTER_NOT_OPERATOR = 4;
const STATE_AFTER_MINUS_OPERATOR = 5;
const STATE_AFTER_CLOSE_BRACE = 6;
const STATE_AFTER_CONSTANT = 7;
// Error type constants.
const ERROR_LEVEL = 1;
const ERROR_UNEXPECTED_ENDING = 2;
const ERROR_UNPARSED_CONTENT = 3;
/**
* Shows a validity of trigger expression
*
* @var bool
*/
public $isValid;
/**
* An error message if trigger expression is not valid
*
* @var string
*/
public $error;
/**
* Type of parsing error, on of self::ERROR_* constant or 0 when no errors.
*
* @var int
*/
public $error_type;
/**
* In case of error contain failed position in expression string. Contain -1 when no errors.
*