mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-16 11:58:41 +00:00
bug fixes and template adjustments
This commit is contained in:
parent
269cd5cab8
commit
eac68f4185
|
|
@ -784,7 +784,9 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
|
||||
/** @var self $mapper */
|
||||
$mapper = static::$hasMany[$propertyName]['mapper'];
|
||||
$internalName = isset($mapper::$columns[static::$hasMany[$propertyName]['self']]) ? $mapper::$columns[static::$hasMany[$propertyName]['self']]['internal'] : 'ERROR';
|
||||
$internalName = isset($mapper::$columns[static::$hasMany[$propertyName]['self']])
|
||||
? $mapper::$columns[static::$hasMany[$propertyName]['self']]['internal']
|
||||
: 'ERROR';
|
||||
|
||||
if (\is_object($values)) {
|
||||
// conditionals
|
||||
|
|
@ -2037,7 +2039,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
if (!$refProp->isPublic()) {
|
||||
$refProp->setAccessible(true);
|
||||
// @todo: \is_array($values) is weird, was necessary for the itemmanagement list at some point, but only suddenly????!!!!
|
||||
$refProp->setValue($obj, !\is_array($objects) && (!isset(static::$hasMany[$member]['conditional']) || \is_array($values))
|
||||
$refProp->setValue($obj, !\is_array($objects) && (!isset(static::$hasMany[$member]['conditional']) || (\is_array($values) && \count($values) > 1))
|
||||
? [$mapper::getObjectId($objects) => $objects]
|
||||
: $objects
|
||||
);
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ final class ConsoleResponse extends ResponseAbstract implements RenderableInterf
|
|||
/**
|
||||
* Generate response based on header.
|
||||
*
|
||||
* @param mixed $data Data passt to render function. (0 => bool: $optimize)
|
||||
* @param mixed ...$data Data passt to render function. (0 => bool: $optimize)
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ final class SocketResponse extends ResponseAbstract implements RenderableInterfa
|
|||
/**
|
||||
* Generate response based on header.
|
||||
*
|
||||
* @param mixed $data Data passt to render function. (0 => bool: $optimize)
|
||||
* @param mixed ...$data Data passt to render function. (0 => bool: $optimize)
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
|
|
|
|||
|
|
@ -490,24 +490,27 @@ class Graph
|
|||
/**
|
||||
* Perform depth first traversal
|
||||
*
|
||||
* @param int|string|Node $node1 Graph node
|
||||
* @param int|string|Node $node2 Graph node
|
||||
* @param Node $node1 Graph node
|
||||
* @param Node $node2 Graph node
|
||||
* @param array $visited Is the node already visited
|
||||
* @param array $path Array of nodes (a path through the graph = connected nodes)
|
||||
* @param array $paths Array of paths (all identified paths)
|
||||
*
|
||||
* @return array
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function depthFirstTraversal(
|
||||
int | string | Node $node1,
|
||||
int | string | Node $node2 = null,
|
||||
Node $node1,
|
||||
Node $node2 = null,
|
||||
array &$visited,
|
||||
array &$path,
|
||||
array &$paths
|
||||
) : array
|
||||
) : void
|
||||
{
|
||||
$visited[$node1->getId()] = true;
|
||||
|
||||
if ($node1->isEquals($node2)) {
|
||||
if ($node2 !== null && $node1->isEqual($node2)) {
|
||||
$paths[] = $path;
|
||||
}
|
||||
|
||||
|
|
@ -515,7 +518,7 @@ class Graph
|
|||
foreach ($neighbors as $neighbor) {
|
||||
if (!isset($visited[$neighbor->getId()]) || !$visited[$neighbor->getId()]) {
|
||||
$path[] = $neighbor;
|
||||
$this->depthFirstTraversal($neighbor, $node2, $visited, $path);
|
||||
$this->depthFirstTraversal($neighbor, $node2, $visited, $path, $paths);
|
||||
\array_pop($path);
|
||||
}
|
||||
}
|
||||
|
|
@ -540,6 +543,10 @@ class Graph
|
|||
$node1 = $this->getNode($node1);
|
||||
}
|
||||
|
||||
if ($node1 === null) {
|
||||
return $nodes;
|
||||
}
|
||||
|
||||
$visited = [];
|
||||
$stack = [];
|
||||
$stack[] = $node1;
|
||||
|
|
@ -647,6 +654,18 @@ class Graph
|
|||
*/
|
||||
public function longestPathBetweenNodes(int | string | Node $node1, int | string | Node $node2) : array
|
||||
{
|
||||
if (!($node1 instanceof Node)) {
|
||||
$node1 = $this->getNode($node1);
|
||||
}
|
||||
|
||||
if (!($node2 instanceof Node)) {
|
||||
$node2 = $this->getNode($node2);
|
||||
}
|
||||
|
||||
if ($node1 === null || $node2 === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$paths = $this->getAllPathsBetweenNodes($node1, $node2);
|
||||
|
||||
if (empty($paths)) {
|
||||
|
|
@ -656,7 +675,7 @@ class Graph
|
|||
foreach ($paths as $key => $path) {
|
||||
$edges[$key] = 0;
|
||||
foreach ($path as $node) {
|
||||
$edges[$key] += $node->getEdgeByNeighbor()->getWeight();
|
||||
$edges[$key] += $node1->getEdgeByNeighbor($node)->getWeight();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -677,15 +696,32 @@ class Graph
|
|||
*/
|
||||
public function shortestPathBetweenNodes(int | string | Node $node1, int | string | Node $node2) : array
|
||||
{
|
||||
if (!($node1 instanceof Node)) {
|
||||
$node1 = $this->getNode($node1);
|
||||
}
|
||||
|
||||
if (!($node2 instanceof Node)) {
|
||||
$node2 = $this->getNode($node2);
|
||||
}
|
||||
|
||||
if ($node1 === null || $node2 === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$paths = $this->getAllPathsBetweenNodes($node1, $node2);
|
||||
|
||||
$edges = [];
|
||||
foreach ($paths as $key => $path) {
|
||||
$edges[$key] = 0;
|
||||
foreach ($path as $node) {
|
||||
$edges[$key] += $node->getEdgeByNeighbor()->getWeight();
|
||||
$edges[$key] += $node1->getEdgeByNeighbor($node)->getWeight();
|
||||
}
|
||||
}
|
||||
|
||||
if ($edges === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
\asort($edges);
|
||||
|
||||
return $paths[\array_key_first($edges)];
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class Text
|
|||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $hasFormatting = false;
|
||||
public bool $hasFormatting = false;
|
||||
|
||||
/**
|
||||
* Text has paragraphs.
|
||||
|
|
@ -63,7 +63,7 @@ class Text
|
|||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $hasParagraphs = false;
|
||||
public bool $hasParagraphs = false;
|
||||
|
||||
/**
|
||||
* Amount of sentences of the last generated text.
|
||||
|
|
@ -71,7 +71,7 @@ class Text
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $sentences = 0;
|
||||
public int $sentences = 0;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
@ -82,51 +82,11 @@ class Text
|
|||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(bool $hasFormatting = false, bool $hasParagraphs = false)
|
||||
{
|
||||
$this->setFormatting($hasFormatting);
|
||||
$this->setParagraphs($hasParagraphs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if the text should have formatting.
|
||||
*
|
||||
* @param bool $hasFormatting text has formatting
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setFormatting(bool $hasFormatting) : void
|
||||
{
|
||||
$this->hasFormatting = $hasFormatting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if the text should have paragraphs.
|
||||
*
|
||||
* @param bool $hasParagraphs Text has paragraphs
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setParagraphs(bool $hasParagraphs) : void
|
||||
{
|
||||
$this->hasParagraphs = $hasParagraphs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Amount of sentences of the last generated text.
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getSentences() : int
|
||||
{
|
||||
return $this->sentences;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a random string.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
"require-dev": {
|
||||
"phpunit/phpunit": ">=9.4",
|
||||
"friendsofphp/php-cs-fixer": ">=3.0",
|
||||
"squizlabs/php_codesniffer": ">=3.5",
|
||||
"squizlabs/php_codesniffer": ">=3.6",
|
||||
"phpmd/phpmd": ">=2.9",
|
||||
"phpstan/phpstan": ">=0.12.58",
|
||||
"phan/phan": ">=3.2.6"
|
||||
|
|
|
|||
|
|
@ -38,7 +38,5 @@ class TextTest extends \PHPUnit\Framework\TestCase
|
|||
$text->generateText(300),
|
||||
$text->generateText(300)
|
||||
);
|
||||
|
||||
self::assertGreaterThan(0, $text->getSentences());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user