Update yaml, remove php 5.4 array syntax from jpgraph. (#6620)

This commit is contained in:
Tony Murray
2017-05-10 02:21:06 -05:00
committed by Neil Lathwood
parent b0c1885d73
commit fe25e207ab
22 changed files with 457 additions and 222 deletions

View File

@@ -62,7 +62,7 @@ class DateScale extends LinearScale
assert($aMin <= $aMax);
$this->type = $aType;
$this->scale = [$aMin, $aMax];
$this->scale = array($aMin, $aMax);
$this->world_size = $aMax - $aMin;
$this->ticks = new LinearTicks();
$this->intscale = true;
@@ -83,7 +83,7 @@ class DateScale extends LinearScale
$i = 0;
$s = 0;
if ($aYearType !== false) {
$yearAdj = [0 => 1, 1 => 2, 2 => 5];
$yearAdj = array(0 => 1, 1 => 2, 2 => 5);
if ($aRound == 0) {
$y = floor($y / $yearAdj[$aYearType]) * $yearAdj[$aYearType];
} else {
@@ -93,7 +93,7 @@ class DateScale extends LinearScale
$m = 1;
$d = 1;
} elseif ($aMonthType !== false) {
$monthAdj = [0 => 1, 1 => 6];
$monthAdj = array(0 => 1, 1 => 6);
if ($aRound == 0) {
$m = floor($m / $monthAdj[$aMonthType]) * $monthAdj[$aMonthType];
$d = 1;
@@ -170,7 +170,7 @@ class DateScale extends LinearScale
$s = (int) date('s', $aTime);
if ($aHourType !== false) {
$aHourType %= 6;
$hourAdj = [0 => 1, 1 => 2, 2 => 3, 3 => 4, 4 => 6, 5 => 12];
$hourAdj = array(0 => 1, 1 => 2, 2 => 3, 3 => 4, 4 => 6, 5 => 12);
if ($aRound == 0) {
$h = floor($h / $hourAdj[$aHourType]) * $hourAdj[$aHourType];
} else {
@@ -190,7 +190,7 @@ class DateScale extends LinearScale
$s = 0;
} elseif ($aMinType !== false) {
$aMinType %= 5;
$minAdj = [0 => 1, 1 => 5, 2 => 10, 3 => 15, 4 => 30];
$minAdj = array(0 => 1, 1 => 5, 2 => 10, 3 => 15, 4 => 30);
if ($aRound == 0) {
$i = floor($i / $minAdj[$aMinType]) * $minAdj[$aMinType];
} else {
@@ -210,7 +210,7 @@ class DateScale extends LinearScale
$s = 0;
} elseif ($aSecType !== false) {
$aSecType %= 5;
$secAdj = [0 => 1, 1 => 5, 2 => 10, 3 => 15, 4 => 30];
$secAdj = array(0 => 1, 1 => 5, 2 => 10, 3 => 15, 4 => 30);
if ($aRound == 0) {
$s = floor($s / $secAdj[$aSecType]) * $secAdj[$aSecType];
} else {
@@ -262,70 +262,70 @@ class DateScale extends LinearScale
// array( 0=date-adjust, 1=time-adjust, adjustment-alignment) )
//
$scalePoints =
[
array(
/* Intervall larger than 10 years */
SECPERYEAR * 10, [[SECPERYEAR * 5, SECPERYEAR * 2],
[SECPERYEAR],
[0, YEARADJ_1, 0, YEARADJ_1]],
SECPERYEAR * 10, array(array(SECPERYEAR * 5, SECPERYEAR * 2),
array(SECPERYEAR),
array(0, YEARADJ_1, 0, YEARADJ_1)),
/* Intervall larger than 2 years */
SECPERYEAR * 2, [[SECPERYEAR], [SECPERYEAR],
[0, YEARADJ_1]],
SECPERYEAR * 2, array(array(SECPERYEAR), array(SECPERYEAR),
array(0, YEARADJ_1)),
/* Intervall larger than 90 days (approx 3 month) */
SECPERDAY * 90, [[SECPERDAY * 30, SECPERDAY * 14, SECPERDAY * 7, SECPERDAY],
[SECPERDAY * 5, SECPERDAY * 7, SECPERDAY, SECPERDAY],
[0, MONTHADJ_1, 0, DAYADJ_WEEK, 0, DAYADJ_1, 0, DAYADJ_1]],
SECPERDAY * 90, array(array(SECPERDAY * 30, SECPERDAY * 14, SECPERDAY * 7, SECPERDAY),
array(SECPERDAY * 5, SECPERDAY * 7, SECPERDAY, SECPERDAY),
array(0, MONTHADJ_1, 0, DAYADJ_WEEK, 0, DAYADJ_1, 0, DAYADJ_1)),
/* Intervall larger than 30 days (approx 1 month) */
SECPERDAY * 30, [[SECPERDAY * 14, SECPERDAY * 7, SECPERDAY * 2, SECPERDAY],
[SECPERDAY, SECPERDAY, SECPERDAY, SECPERDAY],
[0, DAYADJ_WEEK, 0, DAYADJ_1, 0, DAYADJ_1, 0, DAYADJ_1]],
SECPERDAY * 30, array(array(SECPERDAY * 14, SECPERDAY * 7, SECPERDAY * 2, SECPERDAY),
array(SECPERDAY, SECPERDAY, SECPERDAY, SECPERDAY),
array(0, DAYADJ_WEEK, 0, DAYADJ_1, 0, DAYADJ_1, 0, DAYADJ_1)),
/* Intervall larger than 7 days */
SECPERDAY * 7, [[SECPERDAY, SECPERHOUR * 12, SECPERHOUR * 6, SECPERHOUR * 2],
[SECPERHOUR * 6, SECPERHOUR * 3, SECPERHOUR, SECPERHOUR],
[0, DAYADJ_1, 1, HOURADJ_12, 1, HOURADJ_6, 1, HOURADJ_1]],
SECPERDAY * 7, array(array(SECPERDAY, SECPERHOUR * 12, SECPERHOUR * 6, SECPERHOUR * 2),
array(SECPERHOUR * 6, SECPERHOUR * 3, SECPERHOUR, SECPERHOUR),
array(0, DAYADJ_1, 1, HOURADJ_12, 1, HOURADJ_6, 1, HOURADJ_1)),
/* Intervall larger than 1 day */
SECPERDAY, [[SECPERDAY, SECPERHOUR * 12, SECPERHOUR * 6, SECPERHOUR * 2, SECPERHOUR],
[SECPERHOUR * 6, SECPERHOUR * 2, SECPERHOUR, SECPERHOUR, SECPERHOUR],
[1, HOURADJ_12, 1, HOURADJ_6, 1, HOURADJ_1, 1, HOURADJ_1]],
SECPERDAY, array(array(SECPERDAY, SECPERHOUR * 12, SECPERHOUR * 6, SECPERHOUR * 2, SECPERHOUR),
array(SECPERHOUR * 6, SECPERHOUR * 2, SECPERHOUR, SECPERHOUR, SECPERHOUR),
array(1, HOURADJ_12, 1, HOURADJ_6, 1, HOURADJ_1, 1, HOURADJ_1)),
/* Intervall larger than 12 hours */
SECPERHOUR * 12, [[SECPERHOUR * 2, SECPERHOUR, SECPERMIN * 30, 900, 600],
[1800, 1800, 900, 300, 300],
[1, HOURADJ_1, 1, MINADJ_30, 1, MINADJ_15, 1, MINADJ_10, 1, MINADJ_5]],
SECPERHOUR * 12, array(array(SECPERHOUR * 2, SECPERHOUR, SECPERMIN * 30, 900, 600),
array(1800, 1800, 900, 300, 300),
array(1, HOURADJ_1, 1, MINADJ_30, 1, MINADJ_15, 1, MINADJ_10, 1, MINADJ_5)),
/* Intervall larger than 2 hours */
SECPERHOUR * 2, [[SECPERHOUR, SECPERMIN * 30, 900, 600, 300],
[1800, 900, 300, 120, 60],
[1, HOURADJ_1, 1, MINADJ_30, 1, MINADJ_15, 1, MINADJ_10, 1, MINADJ_5]],
SECPERHOUR * 2, array(array(SECPERHOUR, SECPERMIN * 30, 900, 600, 300),
array(1800, 900, 300, 120, 60),
array(1, HOURADJ_1, 1, MINADJ_30, 1, MINADJ_15, 1, MINADJ_10, 1, MINADJ_5)),
/* Intervall larger than 1 hours */
SECPERHOUR, [[SECPERMIN * 30, 900, 600, 300], [900, 300, 120, 60],
[1, MINADJ_30, 1, MINADJ_15, 1, MINADJ_10, 1, MINADJ_5]],
SECPERHOUR, array(array(SECPERMIN * 30, 900, 600, 300), array(900, 300, 120, 60),
array(1, MINADJ_30, 1, MINADJ_15, 1, MINADJ_10, 1, MINADJ_5)),
/* Intervall larger than 30 min */
SECPERMIN * 30, [[SECPERMIN * 15, SECPERMIN * 10, SECPERMIN * 5, SECPERMIN],
[300, 300, 60, 10],
[1, MINADJ_15, 1, MINADJ_10, 1, MINADJ_5, 1, MINADJ_1]],
SECPERMIN * 30, array(array(SECPERMIN * 15, SECPERMIN * 10, SECPERMIN * 5, SECPERMIN),
array(300, 300, 60, 10),
array(1, MINADJ_15, 1, MINADJ_10, 1, MINADJ_5, 1, MINADJ_1)),
/* Intervall larger than 1 min */
SECPERMIN, [[SECPERMIN, 15, 10, 5],
[15, 5, 2, 1],
[1, MINADJ_1, 1, SECADJ_15, 1, SECADJ_10, 1, SECADJ_5]],
SECPERMIN, array(array(SECPERMIN, 15, 10, 5),
array(15, 5, 2, 1),
array(1, MINADJ_1, 1, SECADJ_15, 1, SECADJ_10, 1, SECADJ_5)),
/* Intervall larger than 10 sec */
10, [[5, 2],
[1, 1],
[1, SECADJ_5, 1, SECADJ_1]],
10, array(array(5, 2),
array(1, 1),
array(1, SECADJ_5, 1, SECADJ_1)),
/* Intervall larger than 1 sec */
1, [[1],
[1],
[1, SECADJ_1]],
];
1, array(array(1),
array(1),
array(1, SECADJ_1)),
);
$ns = count($scalePoints);
// Establish major and minor scale units for the date scale
@@ -395,7 +395,7 @@ class DateScale extends LinearScale
}
++$i;
}
return [$start, $end, $major, $minor, $format];
return array($start, $end, $major, $minor, $format);
}
// Overrides the automatic determined date format. Must be a valid date() format string

View File

@@ -96,7 +96,7 @@ class PolarAxis extends Axis
$this->scale->ticks->Stroke($this->img, $this->scale, $pos);
// Stroke the minor arcs
$pmin = [];
$pmin = array();
$p = $this->scale->ticks->ticks_pos;
$n = count($p);
$i = 0;

View File

@@ -46,6 +46,6 @@ class PolarLogScale extends LogScale
} else {
$y = ($this->graph->img->top_margin + $this->graph->img->plotheight) - $y;
}
return [$x, $y];
return array($x, $y);
}
}

View File

@@ -45,6 +45,6 @@ class PolarScale extends LinearScale
} else {
$y = ($this->graph->img->top_margin + $this->graph->img->plotheight) - $y;
}
return [$x, $y];
return array($x, $y);
}
}

View File

@@ -9,7 +9,7 @@ use Amenadiel\JpGraph\Util;
class WindroseGraph extends Graph
{
private $posx, $posy;
public $plots = [];
public $plots = array();
public function __construct($width = 300, $height = 200, $cachedName = "", $timeout = 0, $inline = 1)
{

View File

@@ -38,7 +38,7 @@ class PolarPlot
public $legendcsimtarget = '';
public $legendcsimalt = '';
public $legend = "";
public $csimtargets = []; // Array of targets for CSIM
public $csimtargets = array(); // Array of targets for CSIM
public $csimareas = ""; // Resultant CSIM area tags
public $csimalts = null; // ALT:s for corresponding target
public $scale = null;
@@ -126,7 +126,7 @@ class PolarPlot
{
$i = 0;
$p = [];
$p = array();
$this->csimareas = '';
while ($i < $this->numpoints) {
list($x1, $y1) = $scale->PTranslate($this->coord[2 * $i], $this->coord[2 * $i + 1]);

View File

@@ -38,27 +38,27 @@ define('RANGE_DISCRETE', 1);
class WindrosePlot
{
private $iAntiAlias = true;
private $iData = [];
private $iData = array();
public $iX = 0.5, $iY = 0.5;
public $iSize = 0.55;
private $iGridColor1 = 'gray', $iGridColor2 = 'darkgreen';
private $iRadialColorArray = [];
private $iRadialWeightArray = [];
private $iRadialStyleArray = [];
private $iRanges = [1, 2, 3, 5, 6, 10, 13.5, 99.0];
private $iRadialColorArray = array();
private $iRadialWeightArray = array();
private $iRadialStyleArray = array();
private $iRanges = array(1, 2, 3, 5, 6, 10, 13.5, 99.0);
private $iRangeStyle = RANGE_OVERLAPPING;
public $iCenterSize = 60;
private $iType = WINDROSE_TYPE16;
public $iFontFamily = FF_VERDANA, $iFontStyle = FS_NORMAL, $iFontSize = 10;
public $iFontColor = 'darkgray';
private $iRadialGridStyle = 'longdashed';
private $iAllDirectionLabels = ['E', 'ENE', 'NE', 'NNE', 'N', 'NNW', 'NW', 'WNW', 'W', 'WSW', 'SW', 'SSW', 'S', 'SSE', 'SE', 'ESE'];
private $iStandardDirections = [];
private $iAllDirectionLabels = array('E', 'ENE', 'NE', 'NNE', 'N', 'NNW', 'NW', 'WNW', 'W', 'WSW', 'SW', 'SSW', 'S', 'SSE', 'SE', 'ESE');
private $iStandardDirections = array();
private $iCircGridWeight = 3, $iRadialGridWeight = 1;
private $iLabelMargin = 12;
private $iLegweights = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20];
private $iLegColors = ['orange', 'black', 'blue', 'red', 'green', 'purple', 'navy', 'yellow', 'brown'];
private $iLabelFormatString = '', $iLabels = [];
private $iLegweights = array(2, 4, 6, 8, 10, 12, 14, 16, 18, 20);
private $iLegColors = array('orange', 'black', 'blue', 'red', 'green', 'purple', 'navy', 'yellow', 'brown');
private $iLabelFormatString = '', $iLabels = array();
private $iLabelPositioning = LBLPOSITION_EDGE;
private $iColor = 'white';
private $iShowBox = false, $iBoxColor = 'black', $iBoxWeight = 1, $iBoxStyle = 'solid';
@@ -194,7 +194,7 @@ class WindrosePlot
public function SetRadialGridStyle($aStyle)
{
$aStyle = strtolower($aStyle);
if (!in_array($aStyle, ['solid', 'dotted', 'dashed', 'longdashed'])) {
if (!in_array($aStyle, array('solid', 'dotted', 'dashed', 'longdashed'))) {
Util\JpGraphError::RaiseL(22005); //("Line style for radial lines must be on of ('solid','dotted','dashed','longdashed') ");
}
$this->iRadialGridStyle = $aStyle;
@@ -296,7 +296,7 @@ class WindrosePlot
$x4 = $xt + $weight * sin($a);
$y4 = $yt + $weight * cos($a);
$pts = [$x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4];
$pts = array($x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4);
$aImg->SetColor($color);
$aImg->FilledPolygon($pts);
@@ -441,7 +441,7 @@ class WindrosePlot
} elseif (!empty($this->iData[$i])) {
$data[$i] = $this->iData[$i];
} else {
$data[$i] = [];
$data[$i] = array();
}
}
@@ -593,7 +593,7 @@ class WindrosePlot
// Stroke grid lines for directions and remember the
// position for the labels
$txtpos = [];
$txtpos = array();
$num = count($this->iData);
$keys = array_keys($this->iData);
@@ -637,7 +637,7 @@ class WindrosePlot
$dblImg->SetLineStyle($this->iRadialStyleArray[$dir]);
}
$dblImg->StyleLine($xxc, $yyc, $x, $y);
$txtpos[] = [$x, $y, $a];
$txtpos[] = array($x, $y, $a);
}
$dblImg->SetLineWeight(1);
@@ -753,7 +753,7 @@ class WindrosePlot
// corresponding index.
public function FixupIndexes($aDataArray, $num)
{
$ret = [];
$ret = array();
$keys = array_keys($aDataArray);
foreach ($aDataArray as $idx => $data) {
if (is_string($idx)) {
@@ -811,7 +811,7 @@ class WindrosePlot
$this->iRadialWeightArray = $this->FixupIndexes($this->iRadialWeightArray, $num);
$this->iRadialStyleArray = $this->FixupIndexes($this->iRadialStyleArray, $num);
$txtpos = [];
$txtpos = array();
$a = 2 * M_PI / $num;
$dblImg->SetColor($this->iGridColor2);
$dblImg->SetLineStyle($this->iRadialGridStyle);
@@ -841,7 +841,7 @@ class WindrosePlot
}
$dblImg->StyleLine($xxc, $yyc, $x, $y);
$txtpos[] = [$x, $y, $a * $i];
$txtpos[] = array($x, $y, $a * $i);
}
$dblImg->SetLineWeight(1);
@@ -1156,7 +1156,7 @@ class WindrosePlot
$const1 = 4;
$const2 = 4;
}
$tmp = [];
$tmp = array();
$n = count($this->iData);
foreach ($this->iData as $key => $val) {
if (is_numeric($key)) {

View File

@@ -388,6 +388,8 @@ return array(
'HTMLPurifier_Zipper' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/Zipper.php',
'LibreNMS\\Component' => $baseDir . '/LibreNMS/Component.php',
'LibreNMS\\ComposerHelper' => $baseDir . '/LibreNMS/ComposerHelper.php',
'LibreNMS\\Device\\Sensor' => $baseDir . '/LibreNMS/Device/Sensor.php',
'LibreNMS\\Device\\WirelessSensor' => $baseDir . '/LibreNMS/Device/WirelessSensor.php',
'LibreNMS\\Exceptions\\DatabaseConnectException' => $baseDir . '/LibreNMS/Exceptions/DatabaseConnectException.php',
'LibreNMS\\Exceptions\\FileExistsException' => $baseDir . '/LibreNMS/Exceptions/FileExistsException.php',
'LibreNMS\\Exceptions\\HostExistsException' => $baseDir . '/LibreNMS/Exceptions/HostExistsException.php',
@@ -399,6 +401,56 @@ return array(
'LibreNMS\\Exceptions\\InvalidRrdTypeException' => $baseDir . '/LibreNMS/Exceptions/InvalidRrdTypeException.php',
'LibreNMS\\Exceptions\\SnmpVersionUnsupportedException' => $baseDir . '/LibreNMS/Exceptions/SnmpVersionUnsupportedException.php',
'LibreNMS\\IRCBot' => $baseDir . '/LibreNMS/IRCBot.php',
'LibreNMS\\Interfaces\\Discovery\\DiscoveryModule' => $baseDir . '/LibreNMS/Interfaces/Discovery/DiscoveryModule.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessApCountDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessApCountDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessCapacityDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessCapacityDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessCcqDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessCcqDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessClientsDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessClientsDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessDistanceDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessDistanceDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessErrorRateDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessErrorRateDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessErrorRatioDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessErrorRatioDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessFrequencyDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessFrequencyDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessNoiseFloorDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessNoiseFloorDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessPowerDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessPowerDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessQualityDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessQualityDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessRateDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessRateDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessRssiDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessRssiDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessSnrDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessSnrDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessUtilizationDiscovery' => $baseDir . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessUtilizationDiscovery.php',
'LibreNMS\\Interfaces\\Polling\\PollerModule' => $baseDir . '/LibreNMS/Interfaces/Polling/PollerModule.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessApCountPolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessApCountPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessCapacityPolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessCapacityPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessCcqPolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessCcqPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessClientsPolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessClientsPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessDistancePolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessDistancePolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessErrorRatePolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessErrorRatePolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessErrorRatioPolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessErrorRatioPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessFrequencyPolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessFrequencyPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessNoiseFloorPolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessNoiseFloorPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessPowerPolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessPowerPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessQualityPolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessQualityPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessRatePolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessRatePolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessRssiPolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessRssiPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessSnrPolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessSnrPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessUtilizationPolling' => $baseDir . '/LibreNMS/Interfaces/Polling/Sensors/WirelessUtilizationPolling.php',
'LibreNMS\\OS' => $baseDir . '/LibreNMS/OS.php',
'LibreNMS\\OS\\Airos' => $baseDir . '/LibreNMS/OS/Airos.php',
'LibreNMS\\OS\\AirosAf' => $baseDir . '/LibreNMS/OS/AirosAf.php',
'LibreNMS\\OS\\Airport' => $baseDir . '/LibreNMS/OS/Airport.php',
'LibreNMS\\OS\\Arubaos' => $baseDir . '/LibreNMS/OS/Arubaos.php',
'LibreNMS\\OS\\Ciscowlc' => $baseDir . '/LibreNMS/OS/Ciscowlc.php',
'LibreNMS\\OS\\Deliberant' => $baseDir . '/LibreNMS/OS/Deliberant.php',
'LibreNMS\\OS\\Extendair' => $baseDir . '/LibreNMS/OS/Extendair.php',
'LibreNMS\\OS\\Generic' => $baseDir . '/LibreNMS/OS/Generic.php',
'LibreNMS\\OS\\Helios' => $baseDir . '/LibreNMS/OS/Helios.php',
'LibreNMS\\OS\\Hpmsm' => $baseDir . '/LibreNMS/OS/Hpmsm.php',
'LibreNMS\\OS\\Ios' => $baseDir . '/LibreNMS/OS/Ios.php',
'LibreNMS\\OS\\Mimosa' => $baseDir . '/LibreNMS/OS/Mimosa.php',
'LibreNMS\\OS\\Routeros' => $baseDir . '/LibreNMS/OS/Routeros.php',
'LibreNMS\\OS\\Siklu' => $baseDir . '/LibreNMS/OS/Siklu.php',
'LibreNMS\\OS\\Symbol' => $baseDir . '/LibreNMS/OS/Symbol.php',
'LibreNMS\\OS\\Unifi' => $baseDir . '/LibreNMS/OS/Unifi.php',
'LibreNMS\\OS\\XirrusAos' => $baseDir . '/LibreNMS/OS/XirrusAos.php',
'LibreNMS\\ObjectCache' => $baseDir . '/LibreNMS/ObjectCache.php',
'LibreNMS\\Plugins' => $baseDir . '/LibreNMS/Plugins.php',
'LibreNMS\\Proc' => $baseDir . '/LibreNMS/Proc.php',
@@ -407,8 +459,9 @@ return array(
'LibreNMS\\Tests\\AlertTest' => $baseDir . '/tests/AlertingTest.php',
'LibreNMS\\Tests\\CommonFunctionsTest' => $baseDir . '/tests/CommonFunctionsTest.php',
'LibreNMS\\Tests\\DBSetupTest' => $baseDir . '/tests/DBSetupTest.php',
'LibreNMS\\Tests\\DiscoveryTest' => $baseDir . '/tests/OSDiscoveryTest.php',
'LibreNMS\\Tests\\DBTestCase' => $baseDir . '/tests/DBTestCase.php',
'LibreNMS\\Tests\\FunctionsTest' => $baseDir . '/tests/FunctionsTest.php',
'LibreNMS\\Tests\\OSDiscoveryTest' => $baseDir . '/tests/OSDiscoveryTest.php',
'LibreNMS\\Tests\\RrdDefinitionTest' => $baseDir . '/tests/RrdDefinitionTest.php',
'LibreNMS\\Tests\\RrdtoolTest' => $baseDir . '/tests/RrdtoolTest.php',
'LibreNMS\\Tests\\SVGTest' => $baseDir . '/tests/SVGTest.php',

View File

@@ -508,6 +508,8 @@ class ComposerStaticInit272059f49825f0adab6de160cf59ca72
'HTMLPurifier_Zipper' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier/Zipper.php',
'LibreNMS\\Component' => __DIR__ . '/../..' . '/LibreNMS/Component.php',
'LibreNMS\\ComposerHelper' => __DIR__ . '/../..' . '/LibreNMS/ComposerHelper.php',
'LibreNMS\\Device\\Sensor' => __DIR__ . '/../..' . '/LibreNMS/Device/Sensor.php',
'LibreNMS\\Device\\WirelessSensor' => __DIR__ . '/../..' . '/LibreNMS/Device/WirelessSensor.php',
'LibreNMS\\Exceptions\\DatabaseConnectException' => __DIR__ . '/../..' . '/LibreNMS/Exceptions/DatabaseConnectException.php',
'LibreNMS\\Exceptions\\FileExistsException' => __DIR__ . '/../..' . '/LibreNMS/Exceptions/FileExistsException.php',
'LibreNMS\\Exceptions\\HostExistsException' => __DIR__ . '/../..' . '/LibreNMS/Exceptions/HostExistsException.php',
@@ -519,6 +521,56 @@ class ComposerStaticInit272059f49825f0adab6de160cf59ca72
'LibreNMS\\Exceptions\\InvalidRrdTypeException' => __DIR__ . '/../..' . '/LibreNMS/Exceptions/InvalidRrdTypeException.php',
'LibreNMS\\Exceptions\\SnmpVersionUnsupportedException' => __DIR__ . '/../..' . '/LibreNMS/Exceptions/SnmpVersionUnsupportedException.php',
'LibreNMS\\IRCBot' => __DIR__ . '/../..' . '/LibreNMS/IRCBot.php',
'LibreNMS\\Interfaces\\Discovery\\DiscoveryModule' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/DiscoveryModule.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessApCountDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessApCountDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessCapacityDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessCapacityDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessCcqDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessCcqDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessClientsDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessClientsDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessDistanceDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessDistanceDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessErrorRateDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessErrorRateDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessErrorRatioDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessErrorRatioDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessFrequencyDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessFrequencyDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessNoiseFloorDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessNoiseFloorDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessPowerDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessPowerDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessQualityDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessQualityDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessRateDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessRateDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessRssiDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessRssiDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessSnrDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessSnrDiscovery.php',
'LibreNMS\\Interfaces\\Discovery\\Sensors\\WirelessUtilizationDiscovery' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Discovery/Sensors/WirelessUtilizationDiscovery.php',
'LibreNMS\\Interfaces\\Polling\\PollerModule' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/PollerModule.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessApCountPolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessApCountPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessCapacityPolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessCapacityPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessCcqPolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessCcqPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessClientsPolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessClientsPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessDistancePolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessDistancePolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessErrorRatePolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessErrorRatePolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessErrorRatioPolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessErrorRatioPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessFrequencyPolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessFrequencyPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessNoiseFloorPolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessNoiseFloorPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessPowerPolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessPowerPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessQualityPolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessQualityPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessRatePolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessRatePolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessRssiPolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessRssiPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessSnrPolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessSnrPolling.php',
'LibreNMS\\Interfaces\\Polling\\Sensors\\WirelessUtilizationPolling' => __DIR__ . '/../..' . '/LibreNMS/Interfaces/Polling/Sensors/WirelessUtilizationPolling.php',
'LibreNMS\\OS' => __DIR__ . '/../..' . '/LibreNMS/OS.php',
'LibreNMS\\OS\\Airos' => __DIR__ . '/../..' . '/LibreNMS/OS/Airos.php',
'LibreNMS\\OS\\AirosAf' => __DIR__ . '/../..' . '/LibreNMS/OS/AirosAf.php',
'LibreNMS\\OS\\Airport' => __DIR__ . '/../..' . '/LibreNMS/OS/Airport.php',
'LibreNMS\\OS\\Arubaos' => __DIR__ . '/../..' . '/LibreNMS/OS/Arubaos.php',
'LibreNMS\\OS\\Ciscowlc' => __DIR__ . '/../..' . '/LibreNMS/OS/Ciscowlc.php',
'LibreNMS\\OS\\Deliberant' => __DIR__ . '/../..' . '/LibreNMS/OS/Deliberant.php',
'LibreNMS\\OS\\Extendair' => __DIR__ . '/../..' . '/LibreNMS/OS/Extendair.php',
'LibreNMS\\OS\\Generic' => __DIR__ . '/../..' . '/LibreNMS/OS/Generic.php',
'LibreNMS\\OS\\Helios' => __DIR__ . '/../..' . '/LibreNMS/OS/Helios.php',
'LibreNMS\\OS\\Hpmsm' => __DIR__ . '/../..' . '/LibreNMS/OS/Hpmsm.php',
'LibreNMS\\OS\\Ios' => __DIR__ . '/../..' . '/LibreNMS/OS/Ios.php',
'LibreNMS\\OS\\Mimosa' => __DIR__ . '/../..' . '/LibreNMS/OS/Mimosa.php',
'LibreNMS\\OS\\Routeros' => __DIR__ . '/../..' . '/LibreNMS/OS/Routeros.php',
'LibreNMS\\OS\\Siklu' => __DIR__ . '/../..' . '/LibreNMS/OS/Siklu.php',
'LibreNMS\\OS\\Symbol' => __DIR__ . '/../..' . '/LibreNMS/OS/Symbol.php',
'LibreNMS\\OS\\Unifi' => __DIR__ . '/../..' . '/LibreNMS/OS/Unifi.php',
'LibreNMS\\OS\\XirrusAos' => __DIR__ . '/../..' . '/LibreNMS/OS/XirrusAos.php',
'LibreNMS\\ObjectCache' => __DIR__ . '/../..' . '/LibreNMS/ObjectCache.php',
'LibreNMS\\Plugins' => __DIR__ . '/../..' . '/LibreNMS/Plugins.php',
'LibreNMS\\Proc' => __DIR__ . '/../..' . '/LibreNMS/Proc.php',
@@ -527,8 +579,9 @@ class ComposerStaticInit272059f49825f0adab6de160cf59ca72
'LibreNMS\\Tests\\AlertTest' => __DIR__ . '/../..' . '/tests/AlertingTest.php',
'LibreNMS\\Tests\\CommonFunctionsTest' => __DIR__ . '/../..' . '/tests/CommonFunctionsTest.php',
'LibreNMS\\Tests\\DBSetupTest' => __DIR__ . '/../..' . '/tests/DBSetupTest.php',
'LibreNMS\\Tests\\DiscoveryTest' => __DIR__ . '/../..' . '/tests/OSDiscoveryTest.php',
'LibreNMS\\Tests\\DBTestCase' => __DIR__ . '/../..' . '/tests/DBTestCase.php',
'LibreNMS\\Tests\\FunctionsTest' => __DIR__ . '/../..' . '/tests/FunctionsTest.php',
'LibreNMS\\Tests\\OSDiscoveryTest' => __DIR__ . '/../..' . '/tests/OSDiscoveryTest.php',
'LibreNMS\\Tests\\RrdDefinitionTest' => __DIR__ . '/../..' . '/tests/RrdDefinitionTest.php',
'LibreNMS\\Tests\\RrdtoolTest' => __DIR__ . '/../..' . '/tests/RrdtoolTest.php',
'LibreNMS\\Tests\\SVGTest' => __DIR__ . '/../..' . '/tests/SVGTest.php',

View File

@@ -649,23 +649,23 @@
},
{
"name": "symfony/yaml",
"version": "v2.8.19",
"version_normalized": "2.8.19.0",
"version": "v2.8.20",
"version_normalized": "2.8.20.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "286d84891690b0e2515874717e49360d1c98a703"
"reference": "93ccdde79f4b079c7558da4656a3cb1c50c68e02"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/286d84891690b0e2515874717e49360d1c98a703",
"reference": "286d84891690b0e2515874717e49360d1c98a703",
"url": "https://api.github.com/repos/symfony/yaml/zipball/93ccdde79f4b079c7558da4656a3cb1c50c68e02",
"reference": "93ccdde79f4b079c7558da4656a3cb1c50c68e02",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"time": "2017-03-20 09:41:44",
"time": "2017-05-01 14:31:55",
"type": "library",
"extra": {
"branch-alias": {

View File

@@ -33,13 +33,15 @@ class Escaper
"\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
"\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
"\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9");
"\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9",
);
private static $escaped = array('\\\\', '\\"', '\\\\', '\\"',
'\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a',
'\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f',
'\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17',
'\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f',
'\\N', '\\_', '\\L', '\\P');
'\\N', '\\_', '\\L', '\\P',
);
/**
* Determines if a PHP value would require double quoting in YAML.
@@ -50,7 +52,7 @@ class Escaper
*/
public static function requiresDoubleQuoting($value)
{
return preg_match('/'.self::REGEX_CHARACTER_TO_ESCAPE.'/u', $value);
return 0 < preg_match('/'.self::REGEX_CHARACTER_TO_ESCAPE.'/u', $value);
}
/**
@@ -82,7 +84,7 @@ class Escaper
// Determines if the PHP value contains any single characters that would
// cause it to require single quoting in YAML.
return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
return 0 < preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
}
/**

View File

@@ -26,11 +26,11 @@ class ParseException extends RuntimeException
/**
* Constructor.
*
* @param string $message The error message
* @param int $parsedLine The line where the error occurred
* @param int $snippet The snippet of code near the problem
* @param string $parsedFile The file name where the error occurred
* @param \Exception $previous The previous exception
* @param string $message The error message
* @param int $parsedLine The line where the error occurred
* @param string|null $snippet The snippet of code near the problem
* @param string|null $parsedFile The file name where the error occurred
* @param \Exception|null $previous The previous exception
*/
public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, \Exception $previous = null)
{

View File

@@ -21,7 +21,7 @@ use Symfony\Component\Yaml\Exception\DumpException;
*/
class Inline
{
const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\']*(?:\'\'[^\']*)*)\')';
const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*+(?:\\\\.[^"\\\\]*+)*+)"|\'([^\']*+(?:\'\'[^\']*+)*+)\')';
private static $exceptionOnInvalidType = false;
private static $objectSupport = false;
@@ -149,8 +149,8 @@ class Inline
case Escaper::requiresDoubleQuoting($value):
return Escaper::escapeWithDoubleQuotes($value);
case Escaper::requiresSingleQuoting($value):
case preg_match(self::getHexRegex(), $value):
case preg_match(self::getTimestampRegex(), $value):
case Parser::preg_match(self::getHexRegex(), $value):
case Parser::preg_match(self::getTimestampRegex(), $value):
return Escaper::escapeWithSingleQuotes($value);
default:
return $value;
@@ -212,12 +212,12 @@ class Inline
/**
* Parses a YAML scalar.
*
* @param string $scalar
* @param string $delimiters
* @param array $stringDelimiters
* @param int &$i
* @param bool $evaluate
* @param array $references
* @param string $scalar
* @param string[] $delimiters
* @param string[] $stringDelimiters
* @param int &$i
* @param bool $evaluate
* @param array $references
*
* @return string
*
@@ -244,10 +244,10 @@ class Inline
$i += strlen($output);
// remove comments
if (preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) {
if (Parser::preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) {
$output = substr($output, 0, $match[0][1]);
}
} elseif (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
} elseif (Parser::preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
$output = $match[1];
$i += strlen($output);
} else {
@@ -282,7 +282,7 @@ class Inline
*/
private static function parseQuotedScalar($scalar, &$i)
{
if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
if (!Parser::preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
throw new ParseException(sprintf('Malformed inline YAML string: %s.', substr($scalar, $i)));
}
@@ -453,7 +453,7 @@ class Inline
* @param string $scalar
* @param array $references
*
* @return string A YAML string
* @return mixed The evaluated YAML string
*
* @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved
*/
@@ -530,16 +530,16 @@ class Inline
return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw === (string) $cast) ? $cast : $raw);
case is_numeric($scalar):
case preg_match(self::getHexRegex(), $scalar):
case Parser::preg_match(self::getHexRegex(), $scalar):
return '0x' === $scalar[0].$scalar[1] ? hexdec($scalar) : (float) $scalar;
case '.inf' === $scalarLower:
case '.nan' === $scalarLower:
return -log(0);
case '-.inf' === $scalarLower:
return log(0);
case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
case Parser::preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
return (float) str_replace(',', '', $scalar);
case preg_match(self::getTimestampRegex(), $scalar):
case Parser::preg_match(self::getTimestampRegex(), $scalar):
$timeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
$time = strtotime($scalar);

View File

@@ -1,4 +1,4 @@
Copyright (c) 2004-2016 Fabien Potencier
Copyright (c) 2004-2017 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -61,26 +61,60 @@ class Parser
*/
public function parse($value, $exceptionOnInvalidType = false, $objectSupport = false, $objectForMap = false)
{
if (!preg_match('//u', $value)) {
if (false === preg_match('//u', $value)) {
throw new ParseException('The YAML value does not appear to be valid UTF-8.');
}
$this->currentLineNb = -1;
$this->currentLine = '';
$value = $this->cleanup($value);
$this->lines = explode("\n", $value);
if (null === $this->totalNumberOfLines) {
$this->totalNumberOfLines = count($this->lines);
}
$this->refs = array();
$mbEncoding = null;
$e = null;
$data = null;
if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('UTF-8');
}
try {
$data = $this->doParse($value, $exceptionOnInvalidType, $objectSupport, $objectForMap);
} catch (\Exception $e) {
} catch (\Throwable $e) {
}
if (null !== $mbEncoding) {
mb_internal_encoding($mbEncoding);
}
$this->lines = array();
$this->currentLine = '';
$this->refs = array();
$this->skippedLineNumbers = array();
$this->locallySkippedLineNumbers = array();
if (null !== $e) {
throw $e;
}
return $data;
}
private function doParse($value, $exceptionOnInvalidType = false, $objectSupport = false, $objectForMap = false)
{
$this->currentLineNb = -1;
$this->currentLine = '';
$value = $this->cleanup($value);
$this->lines = explode("\n", $value);
$this->locallySkippedLineNumbers = array();
if (null === $this->totalNumberOfLines) {
$this->totalNumberOfLines = count($this->lines);
}
$data = array();
$context = null;
$allowOverwrite = false;
while ($this->moveToNextLine()) {
if ($this->isCurrentLineEmpty()) {
continue;
@@ -92,13 +126,13 @@ class Parser
}
$isRef = $mergeNode = false;
if (preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) {
if (self::preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+))?$#u', rtrim($this->currentLine), $values)) {
if ($context && 'mapping' == $context) {
throw new ParseException('You cannot define a sequence item when in a mapping', $this->getRealCurrentLineNb() + 1, $this->currentLine);
}
$context = 'sequence';
if (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) {
if (isset($values['value']) && self::preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) {
$isRef = $matches['ref'];
$values['value'] = $matches['value'];
}
@@ -108,7 +142,7 @@ class Parser
$data[] = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(null, true), $exceptionOnInvalidType, $objectSupport, $objectForMap);
} else {
if (isset($values['leadspaces'])
&& preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $values['value'], $matches)
&& self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+))?$#u', rtrim($values['value']), $matches)
) {
// this is a compact notation element, add to next block and parse
$block = $values['value'];
@@ -124,7 +158,10 @@ class Parser
if ($isRef) {
$this->refs[$isRef] = end($data);
}
} elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values) && (false === strpos($values['key'], ' #') || in_array($values['key'][0], array('"', "'")))) {
} elseif (
self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
&& (false === strpos($values['key'], ' #') || in_array($values['key'][0], array('"', "'")))
) {
if ($context && 'sequence' == $context) {
throw new ParseException('You cannot define a mapping item when in a sequence', $this->currentLineNb + 1, $this->currentLine);
}
@@ -161,11 +198,7 @@ class Parser
throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
}
foreach ($refValue as $key => $value) {
if (!isset($data[$key])) {
$data[$key] = $value;
}
}
$data += $refValue; // array union
} else {
if (isset($values['value']) && $values['value'] !== '') {
$value = $values['value'];
@@ -187,23 +220,15 @@ class Parser
throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem);
}
foreach ($parsedItem as $key => $value) {
if (!isset($data[$key])) {
$data[$key] = $value;
}
}
$data += $parsedItem; // array union
}
} else {
// If the value associated with the key is a single mapping node, each of its key/value pairs is inserted into the
// current mapping, unless the key already exists in it.
foreach ($parsed as $key => $value) {
if (!isset($data[$key])) {
$data[$key] = $value;
}
}
$data += $parsed; // array union
}
}
} elseif (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) {
} elseif (isset($values['value']) && self::preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) {
$isRef = $matches['ref'];
$values['value'] = $matches['value'];
}
@@ -255,41 +280,13 @@ class Parser
throw $e;
}
if (isset($mbEncoding)) {
mb_internal_encoding($mbEncoding);
}
return $value;
}
switch (preg_last_error()) {
case PREG_INTERNAL_ERROR:
$error = 'Internal PCRE error.';
break;
case PREG_BACKTRACK_LIMIT_ERROR:
$error = 'pcre.backtrack_limit reached.';
break;
case PREG_RECURSION_LIMIT_ERROR:
$error = 'pcre.recursion_limit reached.';
break;
case PREG_BAD_UTF8_ERROR:
$error = 'Malformed UTF-8 data.';
break;
case PREG_BAD_UTF8_OFFSET_ERROR:
$error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.';
break;
default:
$error = 'Unable to parse.';
}
throw new ParseException($error, $this->getRealCurrentLineNb() + 1, $this->currentLine);
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
}
}
if (isset($mbEncoding)) {
mb_internal_encoding($mbEncoding);
}
if ($objectForMap && !is_object($data) && 'mapping' === $context) {
$object = new \stdClass();
@@ -318,7 +315,7 @@ class Parser
$parser = new self($offset, $this->totalNumberOfLines, $skippedLineNumbers);
$parser->refs = &$this->refs;
return $parser->parse($yaml, $exceptionOnInvalidType, $objectSupport, $objectForMap);
return $parser->doParse($yaml, $exceptionOnInvalidType, $objectSupport, $objectForMap);
}
/**
@@ -429,7 +426,7 @@ class Parser
$previousLineIndentation = $indent;
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) {
if ($isItUnindentedCollection && !$this->isCurrentLineEmpty() && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) {
$this->moveToPreviousLine();
break;
}
@@ -527,7 +524,7 @@ class Parser
return $this->refs[$value];
}
if (preg_match('/^'.self::BLOCK_SCALAR_HEADER_PATTERN.'$/', $value, $matches)) {
if (self::preg_match('/^'.self::BLOCK_SCALAR_HEADER_PATTERN.'$/', $value, $matches)) {
$modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
return $this->parseBlockScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs($modifiers));
@@ -582,7 +579,7 @@ class Parser
// determine indentation if not specified
if (0 === $indentation) {
if (preg_match('/^ +/', $this->currentLine, $matches)) {
if (self::preg_match('/^ +/', $this->currentLine, $matches)) {
$indentation = strlen($matches[0]);
}
}
@@ -593,7 +590,7 @@ class Parser
while (
$notEOF && (
$isCurrentLineBlank ||
preg_match($pattern, $this->currentLine, $matches)
self::preg_match($pattern, $this->currentLine, $matches)
)
) {
if ($isCurrentLineBlank && strlen($this->currentLine) > $indentation) {
@@ -626,7 +623,7 @@ class Parser
$previousLineIndented = false;
$previousLineBlank = false;
for ($i = 0; $i < count($blockLines); ++$i) {
for ($i = 0, $blockLinesCount = count($blockLines); $i < $blockLinesCount; ++$i) {
if ('' === $blockLines[$i]) {
$text .= "\n";
$previousLineIndented = false;
@@ -681,10 +678,7 @@ class Parser
return false;
}
$ret = false;
if ($this->getCurrentLineIndentation() > $currentIndentation) {
$ret = true;
}
$ret = $this->getCurrentLineIndentation() > $currentIndentation;
$this->moveToPreviousLine();
@@ -785,14 +779,7 @@ class Parser
return false;
}
$ret = false;
if (
$this->getCurrentLineIndentation() == $currentIndentation
&&
$this->isStringUnIndentedCollectionItem()
) {
$ret = true;
}
$ret = $this->getCurrentLineIndentation() === $currentIndentation && $this->isStringUnIndentedCollectionItem();
$this->moveToPreviousLine();
@@ -816,6 +803,48 @@ class Parser
*/
private function isBlockScalarHeader()
{
return (bool) preg_match('~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~', $this->currentLine);
return (bool) self::preg_match('~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~', $this->currentLine);
}
/**
* A local wrapper for `preg_match` which will throw a ParseException if there
* is an internal error in the PCRE engine.
*
* This avoids us needing to check for "false" every time PCRE is used
* in the YAML engine
*
* @throws ParseException on a PCRE internal error
*
* @see preg_last_error()
*
* @internal
*/
public static function preg_match($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
{
if (false === $ret = preg_match($pattern, $subject, $matches, $flags, $offset)) {
switch (preg_last_error()) {
case PREG_INTERNAL_ERROR:
$error = 'Internal PCRE error.';
break;
case PREG_BACKTRACK_LIMIT_ERROR:
$error = 'pcre.backtrack_limit reached.';
break;
case PREG_RECURSION_LIMIT_ERROR:
$error = 'pcre.recursion_limit reached.';
break;
case PREG_BAD_UTF8_ERROR:
$error = 'Malformed UTF-8 data.';
break;
case PREG_BAD_UTF8_OFFSET_ERROR:
$error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.';
break;
default:
$error = 'Error.';
}
throw new ParseException($error);
}
return $ret;
}
}

View File

@@ -11,10 +11,11 @@
namespace Symfony\Component\Yaml\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Dumper;
class DumperTest extends \PHPUnit_Framework_TestCase
class DumperTest extends TestCase
{
protected $parser;
protected $dumper;
@@ -209,23 +210,25 @@ EOF;
public function getEscapeSequences()
{
return array(
'null' => array("\t\\0", '"\t\\\\0"'),
'bell' => array("\t\\a", '"\t\\\\a"'),
'backspace' => array("\t\\b", '"\t\\\\b"'),
'horizontal-tab' => array("\t\\t", '"\t\\\\t"'),
'line-feed' => array("\t\\n", '"\t\\\\n"'),
'vertical-tab' => array("\t\\v", '"\t\\\\v"'),
'form-feed' => array("\t\\f", '"\t\\\\f"'),
'carriage-return' => array("\t\\r", '"\t\\\\r"'),
'escape' => array("\t\\e", '"\t\\\\e"'),
'space' => array("\t\\ ", '"\t\\\\ "'),
'double-quote' => array("\t\\\"", '"\t\\\\\\""'),
'slash' => array("\t\\/", '"\t\\\\/"'),
'backslash' => array("\t\\\\", '"\t\\\\\\\\"'),
'next-line' => array("\t\\N", '"\t\\\\N"'),
'non-breaking-space' => array("\t\\<EFBFBD>", '"\t\\\\<5C>"'),
'line-separator' => array("\t\\L", '"\t\\\\L"'),
'paragraph-separator' => array("\t\\P", '"\t\\\\P"'),
'empty string' => array('', "''"),
'null' => array("\x0", '"\\0"'),
'bell' => array("\x7", '"\\a"'),
'backspace' => array("\x8", '"\\b"'),
'horizontal-tab' => array("\t", '"\\t"'),
'line-feed' => array("\n", '"\\n"'),
'vertical-tab' => array("\v", '"\\v"'),
'form-feed' => array("\xC", '"\\f"'),
'carriage-return' => array("\r", '"\\r"'),
'escape' => array("\x1B", '"\\e"'),
'space' => array(' ', "' '"),
'double-quote' => array('"', "'\"'"),
'slash' => array('/', '/'),
'backslash' => array('\\', '\\'),
'next-line' => array("\xC2\x85", '"\\N"'),
'non-breaking-space' => array("\xc2\xa0", '"\\_"'),
'line-separator' => array("\xE2\x80\xA8", '"\\L"'),
'paragraph-separator' => array("\xE2\x80\xA9", '"\\P"'),
'colon' => array(':', "':'"),
);
}

View File

@@ -10,9 +10,11 @@ yaml: |
a: Steve
b: Clark
c: Brian
e: notnull
bar:
a: before
d: other
e: ~
<<: *foo
b: new
x: Oren
@@ -46,13 +48,13 @@ yaml: |
<<: *nestedref
php: |
array(
'foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian'),
'bar' => array('a' => 'before', 'd' => 'other', 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'x' => 'Oren'),
'foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull'),
'bar' => array('a' => 'before', 'd' => 'other', 'e' => null, 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'x' => 'Oren'),
'duplicate' => array('foo' => 'bar'),
'foo2' => array('a' => 'Ballmer'),
'ding' => array('fi', 'fei', 'fo', 'fam'),
'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'),
'head' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam'),
'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'),
'head' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
'taz' => array('a' => 'Steve', 'w' => array('p' => 1234)),
'nested' => array('a' => 'Steve', 'w' => array('p' => 12345), 'd' => 'Doug', 'z' => array('p' => 12345))
)

View File

@@ -11,9 +11,10 @@
namespace Symfony\Component\Yaml\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Yaml\Inline;
class InlineTest extends \PHPUnit_Framework_TestCase
class InlineTest extends TestCase
{
/**
* @dataProvider getTestsForParse
@@ -192,27 +193,42 @@ class InlineTest extends \PHPUnit_Framework_TestCase
/**
* @group legacy
* @dataProvider getReservedIndicators
* @expectedDeprecation Not quoting the scalar "@foo " starting with "@" is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.
* throws \Symfony\Component\Yaml\Exception\ParseException in 3.0
*/
public function testParseUnquotedScalarStartingWithReservedIndicator($indicator)
public function testParseUnquotedScalarStartingWithReservedAtIndicator()
{
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
}
public function getReservedIndicators()
{
return array(array('@'), array('`'));
Inline::parse('{ foo: @foo }');
}
/**
* @group legacy
* @dataProvider getScalarIndicators
* @expectedDeprecation Not quoting the scalar "`foo " starting with "`" is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.
* throws \Symfony\Component\Yaml\Exception\ParseException in 3.0
*/
public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
public function testParseUnquotedScalarStartingWithReservedBacktickIndicator()
{
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
Inline::parse('{ foo: `foo }');
}
/**
* @group legacy
* @expectedDeprecation Not quoting the scalar "|foo " starting with "|" is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.
* throws \Symfony\Component\Yaml\Exception\ParseException in 3.0
*/
public function testParseUnquotedScalarStartingWithLiteralStyleIndicator()
{
Inline::parse('{ foo: |foo }');
}
/**
* @group legacy
* @expectedDeprecation Not quoting the scalar ">foo " starting with ">" is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.
* throws \Symfony\Component\Yaml\Exception\ParseException in 3.0
*/
public function testParseUnquotedScalarStartingWithFoldedStyleIndicator()
{
Inline::parse('{ foo: >foo }');
}
public function getScalarIndicators()
@@ -457,4 +473,25 @@ class InlineTest extends \PHPUnit_Framework_TestCase
{
Inline::parse('{this, is not, supported}');
}
public function testVeryLongQuotedStrings()
{
$longStringWithQuotes = str_repeat("x\r\n\\\"x\"x", 1000);
$yamlString = Inline::dump(array('longStringWithQuotes' => $longStringWithQuotes));
$arrayFromYaml = Inline::parse($yamlString);
$this->assertEquals($longStringWithQuotes, $arrayFromYaml['longStringWithQuotes']);
}
public function testBooleanMappingKeysAreConvertedToStrings()
{
$this->assertSame(array('false' => 'foo'), Inline::parse('{false: foo}'));
$this->assertSame(array('true' => 'foo'), Inline::parse('{true: foo}'));
}
public function testTheEmptyStringIsAValidMappingKey()
{
$this->assertSame(array('' => 'foo'), Inline::parse('{ "": foo }'));
}
}

View File

@@ -11,9 +11,10 @@
namespace Symfony\Component\Yaml\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Yaml\Exception\ParseException;
class ParseExceptionTest extends \PHPUnit_Framework_TestCase
class ParseExceptionTest extends TestCase
{
public function testGetMessage()
{

View File

@@ -11,11 +11,13 @@
namespace Symfony\Component\Yaml\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Yaml\Parser;
class ParserTest extends \PHPUnit_Framework_TestCase
class ParserTest extends TestCase
{
/** @var Parser */
protected $parser;
protected function setUp()
@@ -189,6 +191,22 @@ EOF;
);
$tests['Literal block chomping clip with multiple trailing newlines'] = array($expected, $yaml);
$yaml = <<<'EOF'
foo:
- bar: |
one
two
EOF;
$expected = array(
'foo' => array(
array(
'bar' => "one\n\ntwo",
),
),
);
$tests['Literal block chomping clip with embedded blank line inside unindented collection'] = array($expected, $yaml);
$yaml = <<<'EOF'
foo: |
one
@@ -1140,10 +1158,12 @@ EOT
*/
public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yaml)
{
$this->setExpectedException(
'\Symfony\Component\Yaml\Exception\ParseException',
sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber)
);
if (method_exists($this, 'expectException')) {
$this->expectException('\Symfony\Component\Yaml\Exception\ParseException');
$this->expectExceptionMessage(sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber));
} else {
$this->setExpectedException('\Symfony\Component\Yaml\Exception\ParseException', sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber));
}
$this->parser->parse($yaml);
}
@@ -1200,6 +1220,38 @@ YAML
),
);
}
public function testCanParseVeryLongValue()
{
$longStringWithSpaces = str_repeat('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ', 20000);
$trickyVal = array('x' => $longStringWithSpaces);
$yamlString = Yaml::dump($trickyVal);
$arrayFromYaml = $this->parser->parse($yamlString);
$this->assertEquals($trickyVal, $arrayFromYaml);
}
/**
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
* @expectedExceptionMessage Reference "foo" does not exist at line 2
*/
public function testParserCleansUpReferencesBetweenRuns()
{
$yaml = <<<YAML
foo: &foo
baz: foobar
bar:
<<: *foo
YAML;
$this->parser->parse($yaml);
$yaml = <<<YAML
bar:
<<: *foo
YAML;
$this->parser->parse($yaml);
}
}
class B

View File

@@ -11,9 +11,10 @@
namespace Symfony\Component\Yaml\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Yaml\Yaml;
class YamlTest extends \PHPUnit_Framework_TestCase
class YamlTest extends TestCase
{
public function testParseAndDump()
{

View File

@@ -5,6 +5,8 @@
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
failOnRisky="true"
failOnWarning="true"
>
<php>
<ini name="error_reporting" value="-1" />