SlayerBirden /
datamigration
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Maketok\DataMigration; |
||
| 4 | |||
| 5 | class ArrayMapTest extends \PHPUnit_Framework_TestCase |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @var ArrayMap |
||
| 9 | */ |
||
| 10 | private $map; |
||
| 11 | |||
| 12 | public function setUp() |
||
| 13 | { |
||
| 14 | $this->map = new ArrayMap(); |
||
| 15 | } |
||
| 16 | |||
| 17 | public function testGet() |
||
| 18 | { |
||
| 19 | $this->map->somevar = 1; |
||
|
0 ignored issues
–
show
|
|||
| 20 | |||
| 21 | $this->assertSame(1, $this->map->somevar); |
||
|
0 ignored issues
–
show
The property
somevar does not exist on object<Maketok\DataMigration\ArrayMap>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 22 | $this->assertSame(1, $this->map['somevar']); |
||
| 23 | $this->assertNull($this->map['someothervar']); |
||
| 24 | } |
||
| 25 | |||
| 26 | public function testHas() |
||
| 27 | { |
||
| 28 | $this->map->somevar = 1; |
||
|
0 ignored issues
–
show
The property
somevar does not exist on object<Maketok\DataMigration\ArrayMap>. Since you implemented __set, maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 29 | |||
| 30 | $this->assertTrue(isset($this->map['somevar'])); |
||
| 31 | $this->assertTrue($this->map->offsetExists('somevar')); |
||
| 32 | } |
||
| 33 | |||
| 34 | public function testUnset() |
||
| 35 | { |
||
| 36 | $this->map->somevar = 1; |
||
|
0 ignored issues
–
show
The property
somevar does not exist on object<Maketok\DataMigration\ArrayMap>. Since you implemented __set, maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 37 | unset($this->map['somevar']); |
||
| 38 | |||
| 39 | // should not produce error |
||
| 40 | unset($this->map->someothervar); |
||
| 41 | |||
| 42 | $this->assertFalse(isset($this->map['somevar'])); |
||
| 43 | } |
||
| 44 | |||
| 45 | public function testFill() |
||
| 46 | { |
||
| 47 | $this->map->setState([ |
||
| 48 | 'somevar' => 2 |
||
| 49 | ]); |
||
| 50 | |||
| 51 | $this->assertEquals(2, $this->map->somevar); |
||
|
0 ignored issues
–
show
The property
somevar does not exist on object<Maketok\DataMigration\ArrayMap>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 52 | $this->assertEquals([ |
||
| 53 | 'somevar' => 2 |
||
| 54 | ], $this->map->dumpState()); |
||
| 55 | } |
||
| 56 | |||
| 57 | public function testIncr() |
||
| 58 | { |
||
| 59 | $this->map->somevar = 1; |
||
|
0 ignored issues
–
show
The property
somevar does not exist on object<Maketok\DataMigration\ArrayMap>. Since you implemented __set, maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 60 | $this->map->incr('somevar', 50); |
||
| 61 | $this->map->incr('someothervar', 50, 50); |
||
| 62 | |||
| 63 | $this->assertSame(2, $this->map->somevar); |
||
|
0 ignored issues
–
show
The property
somevar does not exist on object<Maketok\DataMigration\ArrayMap>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 64 | $this->assertSame(50, $this->map->someothervar); |
||
|
0 ignored issues
–
show
The property
someothervar does not exist on object<Maketok\DataMigration\ArrayMap>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 65 | } |
||
| 66 | |||
| 67 | public function testFrozenIncr() |
||
| 68 | { |
||
| 69 | $this->map->somevar = 1; |
||
|
0 ignored issues
–
show
The property
somevar does not exist on object<Maketok\DataMigration\ArrayMap>. Since you implemented __set, maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 70 | $this->map->frozenIncr('somevar', 1, 1); // +1 |
||
| 71 | $this->map->frozenIncr('somevar', 1, 1); // +1 |
||
| 72 | $this->map->frozenIncr('somevar', 1, 1); // +1 |
||
| 73 | $this->map->freeze(); |
||
| 74 | $this->map->frozenIncr('somevar', 1, 1); // do nothing |
||
| 75 | $this->map->frozenIncr('somevar', 1, 1); // do nothing |
||
| 76 | $this->map->unFreeze(); |
||
| 77 | $this->map->frozenIncr('somevar', 1, 5); // +5 |
||
| 78 | $this->map->frozenIncr('somevar', 1, 5); // +5 |
||
| 79 | |||
| 80 | $this->assertSame(14, $this->map->somevar); |
||
|
0 ignored issues
–
show
The property
somevar does not exist on object<Maketok\DataMigration\ArrayMap>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 81 | } |
||
| 82 | |||
| 83 | public function testIterate() |
||
| 84 | { |
||
| 85 | $this->map->setState([ |
||
| 86 | 'somevar' => 2, |
||
| 87 | 'someothervar' => 2, |
||
| 88 | ]); |
||
| 89 | |||
| 90 | $i = 0; |
||
| 91 | foreach ($this->map as $key => $val) { |
||
| 92 | $i++; |
||
| 93 | } |
||
| 94 | |||
| 95 | $this->assertEquals(2, $i); |
||
| 96 | } |
||
| 97 | |||
| 98 | public function testWithClear() |
||
| 99 | { |
||
| 100 | $this->map->setState([ |
||
| 101 | 'somevar' => 2, |
||
| 102 | 'someothervar' => 2, |
||
| 103 | ]); |
||
| 104 | $this->map->clear(); |
||
| 105 | |||
| 106 | $this->assertFalse(isset($this->map['somevar'])); |
||
| 107 | } |
||
| 108 | } |
||
| 109 |
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.