More bug fixes

This commit is contained in:
Dennis Eichhorn 2016-03-27 23:08:58 +02:00
parent 8ebdf58d34
commit 7cc423281c
3 changed files with 10 additions and 6 deletions

View File

@ -134,7 +134,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
/** /**
* Fields to load. * Fields to load.
* *
* @var string[] * @var array[]
* @since 1.0.0 * @since 1.0.0
*/ */
protected $fields = []; protected $fields = [];
@ -404,6 +404,8 @@ abstract class DataMapperAbstract implements DataMapperInterface
if (isset(static::$hasMany[$pname]['mapper']) && static::$hasMany[$pname]['mapper'] === static::$hasMany[$pname]['relationmapper']) { if (isset(static::$hasMany[$pname]['mapper']) && static::$hasMany[$pname]['mapper'] === static::$hasMany[$pname]['relationmapper']) {
$relReflectionClass = new \ReflectionClass(get_class($temp)); $relReflectionClass = new \ReflectionClass(get_class($temp));
} else {
// todo: init other $relReflectionClass?!
} }
foreach ($values as $key => &$value) { foreach ($values as $key => &$value) {
@ -853,13 +855,14 @@ abstract class DataMapperAbstract implements DataMapperInterface
* Get all by custom query. * Get all by custom query.
* *
* @param Builder $query Query * @param Builder $query Query
* @param bool $relations Relations
* *
* @return array * @return array
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getAllByQuery(Builder $query) : array public function getAllByQuery(Builder $query, bool $relations = true) : array
{ {
$sth = $this->db->con->prepare($query->toSql()); $sth = $this->db->con->prepare($query->toSql());
$sth->execute(); $sth->execute();

View File

@ -339,7 +339,7 @@ class Matrix implements ArrayAccess, Iterator
} }
$trianglize = $this->matrix; $trianglize = $this->matrix;
$prod = $this->(upperTrianglize($trianglize)); $prod = $this->upperTrianglize($trianglize);
for($i = 0; $i < $this->n; $i++) { for($i = 0; $i < $this->n; $i++) {
$prod *= $trianglize[$i][$i]; $prod *= $trianglize[$i][$i];

View File

@ -64,8 +64,9 @@ class Numbers
*/ */
public static function selfdescribing(int $n) : bool public static function selfdescribing(int $n) : bool
{ {
foreach (str_split($n) as $place => $value) { $split = str_split($n);
if (substr_count($number, $place) != $value) { foreach ($split as $place => $value) {
if (substr_count($n, $place) != $value) {
return false; return false;
} }
} }
@ -85,7 +86,7 @@ class Numbers
*/ */
public static function isSquare(int $n) : bool public static function isSquare(int $n) : bool
{ {
$goodMask; // 0xC840C04048404040 computed below $goodMask = 0xC840C04048404040; // 0xC840C04048404040 computed below
for ($i = 0; $i < 64; ++$i) { for ($i = 0; $i < 64; ++$i) {
$goodMask |= PHP_INT_MIN >> ($i*$i); $goodMask |= PHP_INT_MIN >> ($i*$i);