mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-12 23:08:41 +00:00
auto fixes
This commit is contained in:
parent
447efca623
commit
4469789af4
|
|
@ -141,7 +141,7 @@ final class DBSCAN
|
||||||
{
|
{
|
||||||
$this->clusters[$c][] = $point;
|
$this->clusters[$c][] = $point;
|
||||||
$this->clusteredPoints[] = $point;
|
$this->clusteredPoints[] = $point;
|
||||||
$nPoint = reset($neighbors);
|
$nPoint = \reset($neighbors);
|
||||||
|
|
||||||
while ($nPoint) {
|
while ($nPoint) {
|
||||||
$neighbors2 = $this->findNeighbors($nPoint, $epsilon);
|
$neighbors2 = $this->findNeighbors($nPoint, $epsilon);
|
||||||
|
|
@ -159,7 +159,7 @@ final class DBSCAN
|
||||||
$this->clusteredPoints[] = $nPoint;
|
$this->clusteredPoints[] = $nPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nPoint = next($neighbors);
|
$nPoint = \next($neighbors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -242,7 +242,7 @@ final class DBSCAN
|
||||||
if (Polygon::isPointInPolygon(
|
if (Polygon::isPointInPolygon(
|
||||||
[
|
[
|
||||||
'x' => \reset($point->coordinates),
|
'x' => \reset($point->coordinates),
|
||||||
'y' => \end($point->coordinates)
|
'y' => \end($point->coordinates),
|
||||||
],
|
],
|
||||||
$hull
|
$hull
|
||||||
) <= 0
|
) <= 0
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,4 @@ class IdleTime
|
||||||
public int $interval = 0;
|
public int $interval = 0;
|
||||||
|
|
||||||
public int $duration = 0; // in seconds
|
public int $duration = 0; // in seconds
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,4 @@ class Machine
|
||||||
public MachineType $type;
|
public MachineType $type;
|
||||||
|
|
||||||
public array $idle = [];
|
public array $idle = [];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,4 @@ final class ScheduleQueue
|
||||||
{
|
{
|
||||||
unset($this->queue[$id]);
|
unset($this->queue[$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link https://jingga.app
|
* @link https://jingga.app
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link https://jingga.app
|
* @link https://jingga.app
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link https://jingga.app
|
* @link https://jingga.app
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link https://jingga.app
|
* @link https://jingga.app
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
@ -108,7 +107,7 @@ class GeneticOptimization
|
||||||
$parameterCount = \count(\reset($population));
|
$parameterCount = \count(\reset($population));
|
||||||
|
|
||||||
// Genetic Algorithm Loop
|
// Genetic Algorithm Loop
|
||||||
for ($generation = 0; $generation < $generations; $generation++) {
|
for ($generation = 0; $generation < $generations; ++$generation) {
|
||||||
$fitnessScores = [];
|
$fitnessScores = [];
|
||||||
foreach ($population as $parameters) {
|
foreach ($population as $parameters) {
|
||||||
$fitnessScores[] = ($fitness)($parameters);
|
$fitnessScores[] = ($fitness)($parameters);
|
||||||
|
|
@ -116,7 +115,7 @@ class GeneticOptimization
|
||||||
|
|
||||||
// Select parents for crossover based on fitness scores
|
// Select parents for crossover based on fitness scores
|
||||||
$parents = [];
|
$parents = [];
|
||||||
for ($i = 0; $i < $populationSize; $i++) {
|
for ($i = 0; $i < $populationSize; ++$i) {
|
||||||
do {
|
do {
|
||||||
$parentIndex1 = \array_rand($population);
|
$parentIndex1 = \array_rand($population);
|
||||||
$parentIndex2 = \array_rand($population);
|
$parentIndex2 = \array_rand($population);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link https://jingga.app
|
* @link https://jingga.app
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link https://jingga.app
|
* @link https://jingga.app
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link https://jingga.app
|
* @link https://jingga.app
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
@ -77,7 +76,7 @@ class SimulatedAnnealing
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
function optimize(
|
public function optimize(
|
||||||
array $space,
|
array $space,
|
||||||
int $initialTemperature,
|
int $initialTemperature,
|
||||||
\Closure $costFunction,
|
\Closure $costFunction,
|
||||||
|
|
@ -96,7 +95,7 @@ class SimulatedAnnealing
|
||||||
|
|
||||||
$newCost = ($costFunction)($newGeneration);
|
$newCost = ($costFunction)($newGeneration);
|
||||||
|
|
||||||
$temperature = $initialTemperature * pow($coolingRate, $i);
|
$temperature = $initialTemperature * \pow($coolingRate, $i);
|
||||||
|
|
||||||
if ($newCost < $currentCost
|
if ($newCost < $currentCost
|
||||||
|| \mt_rand() / \mt_getrandmax() < \exp(($currentCost - $newCost) / $temperature)
|
|| \mt_rand() / \mt_getrandmax() < \exp(($currentCost - $newCost) / $temperature)
|
||||||
|
|
@ -108,7 +107,7 @@ class SimulatedAnnealing
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'solutions' => $currentGeneration,
|
'solutions' => $currentGeneration,
|
||||||
'costs' => $currentCost
|
'costs' => $currentCost,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link https://jingga.app
|
* @link https://jingga.app
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
@ -97,7 +96,7 @@ class TabuSearch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\is_null($bestNeighbor)) {
|
if ($bestNeighbor === null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,7 +107,6 @@ class TabuSearch
|
||||||
|
|
||||||
$currentSolution = $bestNeighbor;
|
$currentSolution = $bestNeighbor;
|
||||||
|
|
||||||
|
|
||||||
if (($score = ($fitness)($bestNeighbor)) > $bestFitness) {
|
if (($score = ($fitness)($bestNeighbor)) > $bestFitness) {
|
||||||
$bestSolution = $bestNeighbor;
|
$bestSolution = $bestNeighbor;
|
||||||
$bestFitness = $score;
|
$bestFitness = $score;
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ final class Glicko1
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'elo' => (int) \max((int) $r, $this->MIN_ELO),
|
'elo' => (int) \max((int) $r, $this->MIN_ELO),
|
||||||
'rd' => (int) \max($RD_, $this->MIN_RD)
|
'rd' => (int) \max($RD_, $this->MIN_RD),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ class TrueSkill
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw margin = epsilon
|
// Draw margin = epsilon
|
||||||
|
|
@ -160,24 +159,20 @@ class TrueSkill
|
||||||
/ (NormalDistribution::getCdf($epsilon - $tAbs, 0.0, 1.0) - NormalDistribution::getCdf(-$epsilon - $tAbs, 0.0, 1.0));
|
/ (NormalDistribution::getCdf($epsilon - $tAbs, 0.0, 1.0) - NormalDistribution::getCdf(-$epsilon - $tAbs, 0.0, 1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildRatingLayer()
|
private function buildRatingLayer() : void
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildPerformanceLayer()
|
private function buildPerformanceLayer() : void
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildTeamPerformanceLayer()
|
private function buildTeamPerformanceLayer() : void
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildTruncLayer()
|
private function buildTruncLayer() : void
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function factorGraphBuilders()
|
private function factorGraphBuilders()
|
||||||
|
|
@ -198,7 +193,7 @@ class TrueSkill
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rating()
|
public function rating() : void
|
||||||
{
|
{
|
||||||
// Start values
|
// Start values
|
||||||
$mu = 25;
|
$mu = 25;
|
||||||
|
|
@ -214,7 +209,6 @@ class TrueSkill
|
||||||
$muPartial = $muOld * ($alpha - 1) * $sigmaNew * $sigmaNew - $muNew * $alpha * $sigmaOld * $sigmaOld
|
$muPartial = $muOld * ($alpha - 1) * $sigmaNew * $sigmaNew - $muNew * $alpha * $sigmaOld * $sigmaOld
|
||||||
/ (($alpha - 1) * $sigmaNew * $sigmaNew - $alpha * $sigmaOld * $sigmaOld);
|
/ (($alpha - 1) * $sigmaNew * $sigmaNew - $alpha * $sigmaOld * $sigmaOld);
|
||||||
|
|
||||||
|
|
||||||
// New
|
// New
|
||||||
$tau = $pi * $mu;
|
$tau = $pi * $mu;
|
||||||
|
|
||||||
|
|
@ -223,12 +217,6 @@ class TrueSkill
|
||||||
|
|
||||||
$K = NormalDistribution::getCdf();
|
$K = NormalDistribution::getCdf();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$pi = 1 / ($sigma * $sigma);
|
$pi = 1 / ($sigma * $sigma);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,13 @@ namespace phpOMS\Business\Recommendation;
|
||||||
final class BayesianPersonalizedRanking
|
final class BayesianPersonalizedRanking
|
||||||
{
|
{
|
||||||
private int $numFactors;
|
private int $numFactors;
|
||||||
|
|
||||||
private float $learningRate;
|
private float $learningRate;
|
||||||
|
|
||||||
private float $regularization;
|
private float $regularization;
|
||||||
|
|
||||||
private array $userFactors = [];
|
private array $userFactors = [];
|
||||||
|
|
||||||
private array $itemFactors = [];
|
private array $itemFactors = [];
|
||||||
|
|
||||||
// num_factors determines the dimensionality of the latent factor space.
|
// num_factors determines the dimensionality of the latent factor space.
|
||||||
|
|
@ -64,7 +67,7 @@ final class BayesianPersonalizedRanking
|
||||||
return $score;
|
return $score;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateFactors($userId, $posItemId, $negItemId) {
|
public function updateFactors($userId, $posItemId, $negItemId) : void {
|
||||||
if (!isset($this->userFactors[$userId])) {
|
if (!isset($this->userFactors[$userId])) {
|
||||||
$this->userFactors[$userId] = $this->generateRandomFactors();
|
$this->userFactors[$userId] = $this->generateRandomFactors();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace phpOMS\DataStorage\Session;
|
namespace phpOMS\DataStorage\Session;
|
||||||
|
|
||||||
use phpOMS\DataStorage\LockException;
|
|
||||||
use phpOMS\Log\FileLogger;
|
use phpOMS\Log\FileLogger;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Session\JWT;
|
use phpOMS\Session\JWT;
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ final class Dispatcher implements DispatcherInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function dispatch(array | string | Callable $controller, mixed ...$data) : array
|
public function dispatch(array | string | callable $controller, mixed ...$data) : array
|
||||||
{
|
{
|
||||||
$views = [];
|
$views = [];
|
||||||
$data = \array_values($data);
|
$data = \array_values($data);
|
||||||
|
|
@ -172,7 +172,7 @@ final class Dispatcher implements DispatcherInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function dispatchClosure(Callable $controller, array $data = null) : mixed
|
private function dispatchClosure(callable $controller, array $data = null) : mixed
|
||||||
{
|
{
|
||||||
return $data === null ? $controller($this->app) : $controller($this->app, ...$data);
|
return $data === null ? $controller($this->app) : $controller($this->app, ...$data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,5 +36,5 @@ interface DispatcherInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function dispatch(array | string | Callable $controller, mixed ...$data) : array;
|
public function dispatch(array | string | callable $controller, mixed ...$data) : array;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ final class EventManager implements \Countable
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function dispatch(array | string | Callable $func, mixed ...$data) : array
|
public function dispatch(array | string | callable $func, mixed ...$data) : array
|
||||||
{
|
{
|
||||||
if (!\is_callable($func)) {
|
if (!\is_callable($func)) {
|
||||||
return [];
|
return [];
|
||||||
|
|
@ -144,7 +144,7 @@ final class EventManager implements \Countable
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function attach(string $group, string | Callable $callback, bool $remove = false, bool $reset = false) : bool
|
public function attach(string $group, string | callable $callback, bool $remove = false, bool $reset = false) : bool
|
||||||
{
|
{
|
||||||
if (!isset($this->callbacks[$group])) {
|
if (!isset($this->callbacks[$group])) {
|
||||||
$this->callbacks[$group] = ['remove' => $remove, 'reset' => $reset, 'callbacks' => []];
|
$this->callbacks[$group] = ['remove' => $remove, 'reset' => $reset, 'callbacks' => []];
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,7 @@ final class Functions
|
||||||
-1.624290004647e-6,1.303655835580e-6,1.5626441722e-8,-8.5238095915e-8,
|
-1.624290004647e-6,1.303655835580e-6,1.5626441722e-8,-8.5238095915e-8,
|
||||||
6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,
|
6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,
|
||||||
9.6467911e-11, 2.394038e-12,-6.886027e-12,8.94487e-13, 3.13092e-13,
|
9.6467911e-11, 2.394038e-12,-6.886027e-12,8.94487e-13, 3.13092e-13,
|
||||||
-1.12708e-13,3.81e-16,7.106e-15,-1.523e-15,-9.4e-17,1.21e-16,-2.8e-17
|
-1.12708e-13,3.81e-16,7.106e-15,-1.523e-15,-9.4e-17,1.21e-16,-2.8e-17,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -343,7 +343,7 @@ final class Functions
|
||||||
}
|
}
|
||||||
|
|
||||||
$pp = ($p < 1.0) ? $p : 2. - $p;
|
$pp = ($p < 1.0) ? $p : 2. - $p;
|
||||||
$t = sqrt(-2. * \log($pp / 2.));
|
$t = \sqrt(-2. * \log($pp / 2.));
|
||||||
$x = -0.70711 * ((2.30753 + $t * 0.27061) / (1. + $t * (0.99229 + $t * 0.04481)) - $t);
|
$x = -0.70711 * ((2.30753 + $t * 0.27061) / (1. + $t * (0.99229 + $t * 0.04481)) - $t);
|
||||||
|
|
||||||
for ($j = 0; $j < 2; ++$j) {
|
for ($j = 0; $j < 2; ++$j) {
|
||||||
|
|
|
||||||
|
|
@ -845,9 +845,9 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
if ($this->isDiagonal()) {
|
if ($this->isDiagonal()) {
|
||||||
$matrix = [];
|
$matrix = [];
|
||||||
|
|
||||||
for ($i = 0; $i < $this->m; $i++) {
|
for ($i = 0; $i < $this->m; ++$i) {
|
||||||
$row = [];
|
$row = [];
|
||||||
for ($j = 0; $j < $this->m; $j++) {
|
for ($j = 0; $j < $this->m; ++$j) {
|
||||||
if ($i === $j) {
|
if ($i === $j) {
|
||||||
$row[] = \pow($this->matrix[$i][$j], $exponent);
|
$row[] = \pow($this->matrix[$i][$j], $exponent);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ final class Integration
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function intLeftRect(float $from, float $to, float $n, Callable $func) : float
|
public static function intLeftRect(float $from, float $to, float $n, callable $func) : float
|
||||||
{
|
{
|
||||||
$h = ($to - $from) / $n;
|
$h = ($to - $from) / $n;
|
||||||
$sum = 0.0;
|
$sum = 0.0;
|
||||||
|
|
@ -61,7 +61,7 @@ final class Integration
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function intRightRect(float $from, float $to, float $n, Callable $func) : float
|
public static function intRightRect(float $from, float $to, float $n, callable $func) : float
|
||||||
{
|
{
|
||||||
$h = ($to - $from) / $n;
|
$h = ($to - $from) / $n;
|
||||||
$sum = 0.0;
|
$sum = 0.0;
|
||||||
|
|
@ -85,7 +85,7 @@ final class Integration
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function intMiddleRect(float $from, float $to, float $n, Callable $func) : float
|
public static function intMiddleRect(float $from, float $to, float $n, callable $func) : float
|
||||||
{
|
{
|
||||||
$h = ($to - $from) / $n;
|
$h = ($to - $from) / $n;
|
||||||
$sum = 0.0;
|
$sum = 0.0;
|
||||||
|
|
@ -109,7 +109,7 @@ final class Integration
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function intTrapezium(float $from, float $to, float $n, Callable $func) : float
|
public static function intTrapezium(float $from, float $to, float $n, callable $func) : float
|
||||||
{
|
{
|
||||||
$h = ($to - $from) / $n;
|
$h = ($to - $from) / $n;
|
||||||
$sum = $func($from) + $func($to);
|
$sum = $func($from) + $func($to);
|
||||||
|
|
@ -133,7 +133,7 @@ final class Integration
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function intSimpson(float $from, float $to, float $n, Callable $func) : float
|
public static function intSimpson(float $from, float $to, float $n, callable $func) : float
|
||||||
{
|
{
|
||||||
$h = ($to - $from) / $n;
|
$h = ($to - $from) / $n;
|
||||||
$sum1 = 0.0;
|
$sum1 = 0.0;
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ final class Bisection
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function root(Callable $func, float $a, float $b, int $maxIterations = 100) : float
|
public static function root(callable $func, float $a, float $b, int $maxIterations = 100) : float
|
||||||
{
|
{
|
||||||
if ($func($a) * $func($b) >= 0) {
|
if ($func($a) * $func($b) >= 0) {
|
||||||
throw new \Exception("Function values at endpoints must have opposite signs.");
|
throw new \Exception("Function values at endpoints must have opposite signs.");
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ final class Illinois
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function root(Callable $func, float $a, float $b, int $maxIterations = 100) : float
|
public static function root(callable $func, float $a, float $b, int $maxIterations = 100) : float
|
||||||
{
|
{
|
||||||
if ($func($a) * $func($b) >= 0) {
|
if ($func($a) * $func($b) >= 0) {
|
||||||
throw new \Exception("Function values at endpoints must have opposite signs.");
|
throw new \Exception("Function values at endpoints must have opposite signs.");
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ final class RegulaFalsi
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function root(Callable $func, float $a, float $b, int $maxIterations = 100) : float
|
public static function root(callable $func, float $a, float $b, int $maxIterations = 100) : float
|
||||||
{
|
{
|
||||||
if ($func($a) * $func($b) >= 0) {
|
if ($func($a) * $func($b) >= 0) {
|
||||||
throw new \Exception("Function values at endpoints must have opposite signs.");
|
throw new \Exception("Function values at endpoints must have opposite signs.");
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ final class Kernels2D
|
||||||
public static function triangularKernel(float $distance, float $bandwidth) : float
|
public static function triangularKernel(float $distance, float $bandwidth) : float
|
||||||
{
|
{
|
||||||
return \abs($distance) <= $bandwidth / 2
|
return \abs($distance) <= $bandwidth / 2
|
||||||
? 1 - abs($distance) / ($bandwidth / 2)
|
? 1 - \abs($distance) / ($bandwidth / 2)
|
||||||
: 0.0;
|
: 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ final class MetricsND
|
||||||
}
|
}
|
||||||
|
|
||||||
$dotProduct = 0;
|
$dotProduct = 0;
|
||||||
for ($i = 0; $i < \count($a); $i++) {
|
for ($i = 0; $i < \count($a); ++$i) {
|
||||||
$dotProduct += $a[$i] * $b[$i];
|
$dotProduct += $a[$i] * $b[$i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ class Markdown
|
||||||
$backLinkElements[] = [
|
$backLinkElements[] = [
|
||||||
'name' => 'a',
|
'name' => 'a',
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'href' => "#fnref$number:$definitionId",
|
'href' => "#fnref{$number}:{$definitionId}",
|
||||||
'rev' => 'footnote',
|
'rev' => 'footnote',
|
||||||
'class' => 'footnote-backref',
|
'class' => 'footnote-backref',
|
||||||
],
|
],
|
||||||
|
|
@ -135,7 +135,7 @@ class Markdown
|
||||||
{
|
{
|
||||||
$textElements[] = [
|
$textElements[] = [
|
||||||
'name' => 'p',
|
'name' => 'p',
|
||||||
'elements' => $backLinkElements
|
'elements' => $backLinkElements,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -200,7 +200,7 @@ class Markdown
|
||||||
|
|
||||||
protected bool $urlsLinked = true;
|
protected bool $urlsLinked = true;
|
||||||
|
|
||||||
function setSafeMode($safeMode)
|
public function setSafeMode($safeMode)
|
||||||
{
|
{
|
||||||
$this->safeMode = (bool) $safeMode;
|
$this->safeMode = (bool) $safeMode;
|
||||||
|
|
||||||
|
|
@ -209,7 +209,7 @@ class Markdown
|
||||||
|
|
||||||
public bool $safeMode = false;
|
public bool $safeMode = false;
|
||||||
|
|
||||||
function setStrictMode($strictMode)
|
public function setStrictMode($strictMode)
|
||||||
{
|
{
|
||||||
$this->strictMode = (bool) $strictMode;
|
$this->strictMode = (bool) $strictMode;
|
||||||
|
|
||||||
|
|
@ -302,7 +302,7 @@ class Markdown
|
||||||
|
|
||||||
while (($beforeTab = \strstr($line, "\t", true)) !== false)
|
while (($beforeTab = \strstr($line, "\t", true)) !== false)
|
||||||
{
|
{
|
||||||
$shortage = 4 - mb_strlen($beforeTab, 'utf-8') % 4;
|
$shortage = 4 - \mb_strlen($beforeTab, 'utf-8') % 4;
|
||||||
|
|
||||||
$line = $beforeTab
|
$line = $beforeTab
|
||||||
. \str_repeat(' ', $shortage)
|
. \str_repeat(' ', $shortage)
|
||||||
|
|
@ -323,7 +323,7 @@ class Markdown
|
||||||
if (isset($CurrentBlock['continuable']))
|
if (isset($CurrentBlock['continuable']))
|
||||||
{
|
{
|
||||||
$methodName = 'block' . $CurrentBlock['type'] . 'Continue';
|
$methodName = 'block' . $CurrentBlock['type'] . 'Continue';
|
||||||
$Block = $this->$methodName($Line, $CurrentBlock);
|
$Block = $this->{$methodName}($Line, $CurrentBlock);
|
||||||
|
|
||||||
if (isset($Block))
|
if (isset($Block))
|
||||||
{
|
{
|
||||||
|
|
@ -336,7 +336,7 @@ class Markdown
|
||||||
if ($this->isBlockCompletable($CurrentBlock['type']))
|
if ($this->isBlockCompletable($CurrentBlock['type']))
|
||||||
{
|
{
|
||||||
$methodName = 'block' . $CurrentBlock['type'] . 'Complete';
|
$methodName = 'block' . $CurrentBlock['type'] . 'Complete';
|
||||||
$CurrentBlock = $this->$methodName($CurrentBlock);
|
$CurrentBlock = $this->{$methodName}($CurrentBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -362,7 +362,7 @@ class Markdown
|
||||||
|
|
||||||
foreach ($blockTypes as $blockType)
|
foreach ($blockTypes as $blockType)
|
||||||
{
|
{
|
||||||
$Block = $this->{"block$blockType"}($Line, $CurrentBlock);
|
$Block = $this->{"block{$blockType}"}($Line, $CurrentBlock);
|
||||||
|
|
||||||
if (isset($Block))
|
if (isset($Block))
|
||||||
{
|
{
|
||||||
|
|
@ -418,7 +418,7 @@ class Markdown
|
||||||
if (isset($CurrentBlock['continuable']) && $this->isBlockCompletable($CurrentBlock['type']))
|
if (isset($CurrentBlock['continuable']) && $this->isBlockCompletable($CurrentBlock['type']))
|
||||||
{
|
{
|
||||||
$methodName = 'block' . $CurrentBlock['type'] . 'Complete';
|
$methodName = 'block' . $CurrentBlock['type'] . 'Complete';
|
||||||
$CurrentBlock = $this->$methodName($CurrentBlock);
|
$CurrentBlock = $this->{$methodName}($CurrentBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
# ~
|
# ~
|
||||||
|
|
@ -452,12 +452,12 @@ class Markdown
|
||||||
|
|
||||||
protected function isBlockContinuable($Type)
|
protected function isBlockContinuable($Type)
|
||||||
{
|
{
|
||||||
return method_exists($this, 'block' . $Type . 'Continue');
|
return \method_exists($this, 'block' . $Type . 'Continue');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function isBlockCompletable($Type)
|
protected function isBlockCompletable($Type)
|
||||||
{
|
{
|
||||||
return method_exists($this, 'block' . $Type . 'Complete');
|
return \method_exists($this, 'block' . $Type . 'Complete');
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -524,7 +524,7 @@ class Markdown
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($Line['text'], '<!--') === 0)
|
if (\strpos($Line['text'], '<!--') === 0)
|
||||||
{
|
{
|
||||||
$Block = [
|
$Block = [
|
||||||
'element' => [
|
'element' => [
|
||||||
|
|
@ -533,7 +533,7 @@ class Markdown
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (strpos($Line['text'], '-->') !== false)
|
if (\strpos($Line['text'], '-->') !== false)
|
||||||
{
|
{
|
||||||
$Block['closed'] = true;
|
$Block['closed'] = true;
|
||||||
}
|
}
|
||||||
|
|
@ -551,7 +551,7 @@ class Markdown
|
||||||
|
|
||||||
$Block['element']['rawHtml'] .= "\n" . $Line['body'];
|
$Block['element']['rawHtml'] .= "\n" . $Line['body'];
|
||||||
|
|
||||||
if (strpos($Line['text'], '-->') !== false)
|
if (\strpos($Line['text'], '-->') !== false)
|
||||||
{
|
{
|
||||||
$Block['closed'] = true;
|
$Block['closed'] = true;
|
||||||
}
|
}
|
||||||
|
|
@ -575,7 +575,7 @@ class Markdown
|
||||||
|
|
||||||
$infostring = \trim(\substr($Line['text'], $openerLength), "\t ");
|
$infostring = \trim(\substr($Line['text'], $openerLength), "\t ");
|
||||||
|
|
||||||
if (strpos($infostring, '`') !== false)
|
if (\strpos($infostring, '`') !== false)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -599,9 +599,9 @@ class Markdown
|
||||||
* U+000A LINE FEED (LF), U+000C FORM FEED (FF), and
|
* U+000A LINE FEED (LF), U+000C FORM FEED (FF), and
|
||||||
* U+000D CARRIAGE RETURN (CR).
|
* U+000D CARRIAGE RETURN (CR).
|
||||||
*/
|
*/
|
||||||
$language = \substr($infostring, 0, strcspn($infostring, " \t\n\f\r"));
|
$language = \substr($infostring, 0, \strcspn($infostring, " \t\n\f\r"));
|
||||||
|
|
||||||
$Element['attributes'] = ['class' => "language-$language"];
|
$Element['attributes'] = ['class' => "language-{$language}"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$Block = [
|
$Block = [
|
||||||
|
|
@ -740,7 +740,7 @@ class Markdown
|
||||||
'handler' => [
|
'handler' => [
|
||||||
'function' => 'lineElements',
|
'function' => 'lineElements',
|
||||||
'argument' => $term,
|
'argument' => $term,
|
||||||
'destination' => 'elements'
|
'destination' => 'elements',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -777,7 +777,7 @@ class Markdown
|
||||||
unset($Block['interrupted']);
|
unset($Block['interrupted']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = \substr($Line['body'], min($Line['indent'], 4));
|
$text = \substr($Line['body'], \min($Line['indent'], 4));
|
||||||
|
|
||||||
$Block['dd']['handler']['argument'] .= "\n" . $text;
|
$Block['dd']['handler']['argument'] .= "\n" . $text;
|
||||||
|
|
||||||
|
|
@ -797,7 +797,7 @@ class Markdown
|
||||||
'handler' => [
|
'handler' => [
|
||||||
'function' => 'lineElements',
|
'function' => 'lineElements',
|
||||||
'argument' => $text,
|
'argument' => $text,
|
||||||
'destination' => 'elements'
|
'destination' => 'elements',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -841,11 +841,11 @@ class Markdown
|
||||||
'function' => 'lineElements',
|
'function' => 'lineElements',
|
||||||
'argument' => $text,
|
'argument' => $text,
|
||||||
'destination' => 'elements',
|
'destination' => 'elements',
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($Block !== null && \preg_match('/[ #]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['handler']['argument'], $matches, PREG_OFFSET_CAPTURE))
|
if ($Block !== null && \preg_match('/[ #]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['handler']['argument'], $matches, \PREG_OFFSET_CAPTURE))
|
||||||
{
|
{
|
||||||
$attributeString = $matches[1][0];
|
$attributeString = $matches[1][0];
|
||||||
|
|
||||||
|
|
@ -870,7 +870,7 @@ class Markdown
|
||||||
|
|
||||||
if ($contentIndent >= 5)
|
if ($contentIndent >= 5)
|
||||||
{
|
{
|
||||||
$contentIndent -= 1;
|
--$contentIndent;
|
||||||
$matches[1] = \substr($matches[1], 0, -$contentIndent);
|
$matches[1] = \substr($matches[1], 0, -$contentIndent);
|
||||||
$matches[3] = \str_repeat(' ', $contentIndent) . $matches[3];
|
$matches[3] = \str_repeat(' ', $contentIndent) . $matches[3];
|
||||||
}
|
}
|
||||||
|
|
@ -919,8 +919,8 @@ class Markdown
|
||||||
'handler' => [
|
'handler' => [
|
||||||
'function' => 'li',
|
'function' => 'li',
|
||||||
'argument' => !empty($matches[3]) ? [$matches[3]] : [],
|
'argument' => !empty($matches[3]) ? [$matches[3]] : [],
|
||||||
'destination' => 'elements'
|
'destination' => 'elements',
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$Block['element']['elements'] []= & $Block['li'];
|
$Block['element']['elements'] []= & $Block['li'];
|
||||||
|
|
@ -969,8 +969,8 @@ class Markdown
|
||||||
'handler' => [
|
'handler' => [
|
||||||
'function' => 'li',
|
'function' => 'li',
|
||||||
'argument' => [$text],
|
'argument' => [$text],
|
||||||
'destination' => 'elements'
|
'destination' => 'elements',
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$Block['element']['elements'] []= & $Block['li'];
|
$Block['element']['elements'] []= & $Block['li'];
|
||||||
|
|
@ -1021,7 +1021,7 @@ class Markdown
|
||||||
{
|
{
|
||||||
foreach ($Block['element']['elements'] as &$li)
|
foreach ($Block['element']['elements'] as &$li)
|
||||||
{
|
{
|
||||||
if (end($li['handler']['argument']) !== '')
|
if (\end($li['handler']['argument']) !== '')
|
||||||
{
|
{
|
||||||
$li['handler']['argument'] []= '';
|
$li['handler']['argument'] []= '';
|
||||||
}
|
}
|
||||||
|
|
@ -1045,7 +1045,7 @@ class Markdown
|
||||||
'function' => 'linesElements',
|
'function' => 'linesElements',
|
||||||
'argument' => (array) $matches[1],
|
'argument' => (array) $matches[1],
|
||||||
'destination' => 'elements',
|
'destination' => 'elements',
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -1082,7 +1082,7 @@ class Markdown
|
||||||
{
|
{
|
||||||
$marker = $Line['text'][0];
|
$marker = $Line['text'][0];
|
||||||
|
|
||||||
if (\substr_count($Line['text'], $marker) >= 3 && \rtrim($Line['text'], " $marker") === '')
|
if (\substr_count($Line['text'], $marker) >= 3 && \rtrim($Line['text'], " {$marker}") === '')
|
||||||
{
|
{
|
||||||
$Block = [
|
$Block = [
|
||||||
'element' => [
|
'element' => [
|
||||||
|
|
@ -1109,7 +1109,7 @@ class Markdown
|
||||||
$Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2';
|
$Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Block !== null && \preg_match('/[ ]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['handler']['argument'], $matches, PREG_OFFSET_CAPTURE))
|
if ($Block !== null && \preg_match('/[ ]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['handler']['argument'], $matches, \PREG_OFFSET_CAPTURE))
|
||||||
{
|
{
|
||||||
$attributeString = $matches[1][0];
|
$attributeString = $matches[1][0];
|
||||||
|
|
||||||
|
|
@ -1132,7 +1132,7 @@ class Markdown
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->DefinitionData['Footnote'][$name]['count'] ++;
|
++$this->DefinitionData['Footnote'][$name]['count'];
|
||||||
|
|
||||||
if (! isset($this->DefinitionData['Footnote'][$name]['number']))
|
if (! isset($this->DefinitionData['Footnote'][$name]['number']))
|
||||||
{
|
{
|
||||||
|
|
@ -1189,7 +1189,7 @@ class Markdown
|
||||||
$length = \strlen($matches[0]);
|
$length = \strlen($matches[0]);
|
||||||
$remainder = \substr($Line['text'], $length);
|
$remainder = \substr($Line['text'], $length);
|
||||||
|
|
||||||
if (trim($remainder) === '')
|
if (\trim($remainder) === '')
|
||||||
{
|
{
|
||||||
if (isset($matches[2]) || \in_array($matches[1], $this->voidElements))
|
if (isset($matches[2]) || \in_array($matches[1], $this->voidElements))
|
||||||
{
|
{
|
||||||
|
|
@ -1222,14 +1222,14 @@ class Markdown
|
||||||
|
|
||||||
if (\preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
|
if (\preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
|
||||||
{
|
{
|
||||||
$Block['depth'] ++;
|
++$Block['depth'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
|
if (\preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
|
||||||
{
|
{
|
||||||
if ($Block['depth'] > 0)
|
if ($Block['depth'] > 0)
|
||||||
{
|
{
|
||||||
$Block['depth'] --;
|
--$Block['depth'];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1261,12 +1261,12 @@ class Markdown
|
||||||
protected function processTag($elementMarkup) # recursive
|
protected function processTag($elementMarkup) # recursive
|
||||||
{
|
{
|
||||||
# http://stackoverflow.com/q/1148928/200145
|
# http://stackoverflow.com/q/1148928/200145
|
||||||
libxml_use_internal_errors(true);
|
\libxml_use_internal_errors(true);
|
||||||
|
|
||||||
$DOMDocument = new \DOMDocument();
|
$DOMDocument = new \DOMDocument();
|
||||||
|
|
||||||
# http://stackoverflow.com/q/11309194/200145
|
# http://stackoverflow.com/q/11309194/200145
|
||||||
$elementMarkup = mb_convert_encoding($elementMarkup, 'HTML-ENTITIES', 'UTF-8');
|
$elementMarkup = \mb_convert_encoding($elementMarkup, 'HTML-ENTITIES', 'UTF-8');
|
||||||
|
|
||||||
# http://stackoverflow.com/q/4879946/200145
|
# http://stackoverflow.com/q/4879946/200145
|
||||||
$DOMDocument->loadHTML($elementMarkup);
|
$DOMDocument->loadHTML($elementMarkup);
|
||||||
|
|
@ -1317,7 +1317,7 @@ class Markdown
|
||||||
|
|
||||||
protected function blockReference($Line)
|
protected function blockReference($Line)
|
||||||
{
|
{
|
||||||
if (strpos($Line['text'], ']') !== false
|
if (\strpos($Line['text'], ']') !== false
|
||||||
&& \preg_match('/^\[(.+?)\]:[ ]*+<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*+$/', $Line['text'], $matches)
|
&& \preg_match('/^\[(.+?)\]:[ ]*+<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*+$/', $Line['text'], $matches)
|
||||||
) {
|
) {
|
||||||
$id = \strtolower($matches[1]);
|
$id = \strtolower($matches[1]);
|
||||||
|
|
@ -1405,7 +1405,7 @@ class Markdown
|
||||||
|
|
||||||
$headerCells = \explode('|', $header);
|
$headerCells = \explode('|', $header);
|
||||||
|
|
||||||
if (count($headerCells) !== \count($alignments))
|
if (\count($headerCells) !== \count($alignments))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1420,7 +1420,7 @@ class Markdown
|
||||||
'function' => 'lineElements',
|
'function' => 'lineElements',
|
||||||
'argument' => $headerCell,
|
'argument' => $headerCell,
|
||||||
'destination' => 'elements',
|
'destination' => 'elements',
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isset($alignments[$index]))
|
if (isset($alignments[$index]))
|
||||||
|
|
@ -1428,7 +1428,7 @@ class Markdown
|
||||||
$alignment = $alignments[$index];
|
$alignment = $alignments[$index];
|
||||||
|
|
||||||
$HeaderElement['attributes'] = [
|
$HeaderElement['attributes'] = [
|
||||||
'style' => "text-align: $alignment;",
|
'style' => "text-align: {$alignment};",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1470,7 +1470,7 @@ class Markdown
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($Block['alignments']) === 1 || $Line['text'][0] === '|' || \strpos($Line['text'], '|'))
|
if (\count($Block['alignments']) === 1 || $Line['text'][0] === '|' || \strpos($Line['text'], '|'))
|
||||||
{
|
{
|
||||||
$Elements = [];
|
$Elements = [];
|
||||||
|
|
||||||
|
|
@ -1479,9 +1479,9 @@ class Markdown
|
||||||
$row = \trim($row);
|
$row = \trim($row);
|
||||||
$row = \trim($row, '|');
|
$row = \trim($row, '|');
|
||||||
|
|
||||||
preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]++`|`)++/', $row, $matches);
|
\preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]++`|`)++/', $row, $matches);
|
||||||
|
|
||||||
$cells = array_slice($matches[0], 0, \count($Block['alignments']));
|
$cells = \array_slice($matches[0], 0, \count($Block['alignments']));
|
||||||
|
|
||||||
foreach ($cells as $index => $cell)
|
foreach ($cells as $index => $cell)
|
||||||
{
|
{
|
||||||
|
|
@ -1493,7 +1493,7 @@ class Markdown
|
||||||
'function' => 'lineElements',
|
'function' => 'lineElements',
|
||||||
'argument' => $cell,
|
'argument' => $cell,
|
||||||
'destination' => 'elements',
|
'destination' => 'elements',
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isset($Block['alignments'][$index]))
|
if (isset($Block['alignments'][$index]))
|
||||||
|
|
@ -1609,7 +1609,7 @@ class Markdown
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$Inline = $this->{"inline$inlineType"}($Excerpt);
|
$Inline = $this->{"inline{$inlineType}"}($Excerpt);
|
||||||
|
|
||||||
if (! isset($Inline))
|
if (! isset($Inline))
|
||||||
{
|
{
|
||||||
|
|
@ -1632,7 +1632,6 @@ class Markdown
|
||||||
|
|
||||||
# cause the new element to 'inherit' our non nestables
|
# cause the new element to 'inherit' our non nestables
|
||||||
|
|
||||||
|
|
||||||
$Inline['element']['nonNestables'] = isset($Inline['element']['nonNestables'])
|
$Inline['element']['nonNestables'] = isset($Inline['element']['nonNestables'])
|
||||||
? \array_merge($Inline['element']['nonNestables'], $nonNestables)
|
? \array_merge($Inline['element']['nonNestables'], $nonNestables)
|
||||||
: $nonNestables
|
: $nonNestables
|
||||||
|
|
@ -1741,14 +1740,14 @@ class Markdown
|
||||||
$commonMarkEmail = '[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]++@'
|
$commonMarkEmail = '[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]++@'
|
||||||
. $hostnameLabel . '(?:\.' . $hostnameLabel . ')*';
|
. $hostnameLabel . '(?:\.' . $hostnameLabel . ')*';
|
||||||
|
|
||||||
if (strpos($Excerpt['text'], '>') !== false
|
if (\strpos($Excerpt['text'], '>') !== false
|
||||||
&& \preg_match("/^<((mailto:)?$commonMarkEmail)>/i", $Excerpt['text'], $matches)
|
&& \preg_match("/^<((mailto:)?{$commonMarkEmail})>/i", $Excerpt['text'], $matches)
|
||||||
){
|
){
|
||||||
$url = $matches[1];
|
$url = $matches[1];
|
||||||
|
|
||||||
if (! isset($matches[2]))
|
if (! isset($matches[2]))
|
||||||
{
|
{
|
||||||
$url = "mailto:$url";
|
$url = "mailto:{$url}";
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
@ -1794,7 +1793,7 @@ class Markdown
|
||||||
'function' => 'lineElements',
|
'function' => 'lineElements',
|
||||||
'argument' => $matches[1],
|
'argument' => $matches[1],
|
||||||
'destination' => 'elements',
|
'destination' => 'elements',
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -1935,7 +1934,7 @@ class Markdown
|
||||||
{
|
{
|
||||||
$Data = [];
|
$Data = [];
|
||||||
|
|
||||||
$attributes = preg_split('/[ ]+/', $attributeString, - 1, PREG_SPLIT_NO_EMPTY);
|
$attributes = \preg_split('/[ ]+/', $attributeString, - 1, \PREG_SPLIT_NO_EMPTY);
|
||||||
|
|
||||||
foreach ($attributes as $attribute)
|
foreach ($attributes as $attribute)
|
||||||
{
|
{
|
||||||
|
|
@ -1951,13 +1950,14 @@ class Markdown
|
||||||
|
|
||||||
if (isset($classes))
|
if (isset($classes))
|
||||||
{
|
{
|
||||||
$Data['class'] = implode(' ', $classes);
|
$Data['class'] = \implode(' ', $classes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $Data;
|
return $Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private $currentAbreviation;
|
private $currentAbreviation;
|
||||||
|
|
||||||
private $currentMeaning;
|
private $currentMeaning;
|
||||||
|
|
||||||
protected function insertAbreviation(array $Element)
|
protected function insertAbreviation(array $Element)
|
||||||
|
|
@ -1973,7 +1973,7 @@ class Markdown
|
||||||
'title' => $this->currentMeaning,
|
'title' => $this->currentMeaning,
|
||||||
],
|
],
|
||||||
'text' => $this->currentAbreviation,
|
'text' => $this->currentAbreviation,
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
$Element['text']
|
$Element['text']
|
||||||
);
|
);
|
||||||
|
|
@ -2026,8 +2026,6 @@ class Markdown
|
||||||
'extent' => \strlen($matches[0]),
|
'extent' => \strlen($matches[0]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function inlineStrikethrough($Excerpt)
|
protected function inlineStrikethrough($Excerpt)
|
||||||
|
|
@ -2047,7 +2045,7 @@ class Markdown
|
||||||
'function' => 'lineElements',
|
'function' => 'lineElements',
|
||||||
'argument' => $matches[1],
|
'argument' => $matches[1],
|
||||||
'destination' => 'elements',
|
'destination' => 'elements',
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -2060,8 +2058,8 @@ class Markdown
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($Excerpt['context'], 'http') !== false
|
if (\strpos($Excerpt['context'], 'http') !== false
|
||||||
&& \preg_match('/\bhttps?+:[\/]{2}[^\s<]+\b\/*+/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE)
|
&& \preg_match('/\bhttps?+:[\/]{2}[^\s<]+\b\/*+/ui', $Excerpt['context'], $matches, \PREG_OFFSET_CAPTURE)
|
||||||
) {
|
) {
|
||||||
$url = $matches[0][0];
|
$url = $matches[0][0];
|
||||||
|
|
||||||
|
|
@ -2083,7 +2081,7 @@ class Markdown
|
||||||
|
|
||||||
protected function inlineUrlTag($Excerpt)
|
protected function inlineUrlTag($Excerpt)
|
||||||
{
|
{
|
||||||
if (strpos($Excerpt['text'], '>') !== false && \preg_match('/^<(\w++:\/{2}[^ >]++)>/i', $Excerpt['text'], $matches))
|
if (\strpos($Excerpt['text'], '>') !== false && \preg_match('/^<(\w++:\/{2}[^ >]++)>/i', $Excerpt['text'], $matches))
|
||||||
{
|
{
|
||||||
$url = $matches[1];
|
$url = $matches[1];
|
||||||
|
|
||||||
|
|
@ -2121,7 +2119,7 @@ class Markdown
|
||||||
$Element['nonNestables'] = [];
|
$Element['nonNestables'] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($Element['handler']))
|
if (\is_string($Element['handler']))
|
||||||
{
|
{
|
||||||
$function = $Element['handler'];
|
$function = $Element['handler'];
|
||||||
$argument = $Element['text'];
|
$argument = $Element['text'];
|
||||||
|
|
@ -2237,7 +2235,7 @@ class Markdown
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$markup .= " $name=\"".self::escape($value).'"';
|
$markup .= " {$name}=\"".self::escape($value).'"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2329,7 +2327,7 @@ class Markdown
|
||||||
$Elements = $this->linesElements($lines);
|
$Elements = $this->linesElements($lines);
|
||||||
|
|
||||||
if (! \in_array('', $lines)
|
if (! \in_array('', $lines)
|
||||||
&& isset($Elements[0]) && isset($Elements[0]['name'])
|
&& isset($Elements[0], $Elements[0]['name'])
|
||||||
&& $Elements[0]['name'] === 'p'
|
&& $Elements[0]['name'] === 'p'
|
||||||
) {
|
) {
|
||||||
unset($Elements[0]['name']);
|
unset($Elements[0]['name']);
|
||||||
|
|
@ -2350,7 +2348,7 @@ class Markdown
|
||||||
{
|
{
|
||||||
$newElements = [];
|
$newElements = [];
|
||||||
|
|
||||||
while (\preg_match($regexp, $text, $matches, PREG_OFFSET_CAPTURE))
|
while (\preg_match($regexp, $text, $matches, \PREG_OFFSET_CAPTURE))
|
||||||
{
|
{
|
||||||
$offset = (int) $matches[0][1];
|
$offset = (int) $matches[0][1];
|
||||||
$before = \substr($text, 0, $offset);
|
$before = \substr($text, 0, $offset);
|
||||||
|
|
@ -2444,7 +2442,7 @@ class Markdown
|
||||||
|
|
||||||
protected static function escape($text, $allowQuotes = false)
|
protected static function escape($text, $allowQuotes = false)
|
||||||
{
|
{
|
||||||
return htmlspecialchars($text, $allowQuotes ? ENT_NOQUOTES : ENT_QUOTES, 'UTF-8');
|
return \htmlspecialchars($text, $allowQuotes ? \ENT_NOQUOTES : \ENT_QUOTES, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function striAtStart($string, $needle)
|
protected static function striAtStart($string, $needle)
|
||||||
|
|
@ -2461,7 +2459,7 @@ class Markdown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function instance($name = 'default')
|
public static function instance($name = 'default')
|
||||||
{
|
{
|
||||||
if (isset(self::$instances[$name]))
|
if (isset(self::$instances[$name]))
|
||||||
{
|
{
|
||||||
|
|
@ -2487,7 +2485,7 @@ class Markdown
|
||||||
# Read-Only
|
# Read-Only
|
||||||
|
|
||||||
protected array $specialCharacters = [
|
protected array $specialCharacters = [
|
||||||
'\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|', '~'
|
'\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|', '~',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected array $StrongRegex = [
|
protected array $StrongRegex = [
|
||||||
|
|
@ -2517,5 +2515,4 @@ class Markdown
|
||||||
'var', 'span',
|
'var', 'span',
|
||||||
'wbr', 'time',
|
'wbr', 'time',
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user