Skip to content

Commit

Permalink
Use PHP 5.4 short array syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
nubs committed Jun 27, 2016
1 parent 8312fe2 commit d5f72c4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
40 changes: 20 additions & 20 deletions tests/LineSegmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class LineSegmentTest extends PHPUnit_Framework_TestCase
*/
public function a()
{
$a = new Point(new Vector(array(2, -1, -5)));
$b = new Point(new Vector(array(3, 2, -7)));
$a = new Point(new Vector([2, -1, -5]));
$b = new Point(new Vector([3, 2, -7]));
$lineSegment = new LineSegment($a, $b);

$this->assertSame($a, $lineSegment->a());
Expand All @@ -42,8 +42,8 @@ public function a()
*/
public function b()
{
$a = new Point(new Vector(array(2, -1, -5)));
$b = new Point(new Vector(array(3, 2, -7)));
$a = new Point(new Vector([2, -1, -5]));
$b = new Point(new Vector([3, 2, -7]));
$lineSegment = new LineSegment($a, $b);

$this->assertSame($b, $lineSegment->b());
Expand All @@ -63,8 +63,8 @@ public function b()
*/
public function constructWithPointsOfDifferentSpace()
{
$a = new Point(new Vector(array(2, -1, -5)));
$b = new Point(new Vector(array('x' => 3, 'y' => 2, 'z' => -7)));
$a = new Point(new Vector([2, -1, -5]));
$b = new Point(new Vector(['x' => 3, 'y' => 2, 'z' => -7]));

new LineSegment($a, $b);
}
Expand All @@ -84,8 +84,8 @@ public function constructWithPointsOfDifferentSpace()
*/
public function isDegenerateWithDegenerateLine()
{
$a = new Point(new Vector(array(1, 7, 5)));
$b = new Point(new Vector(array(1, 7, 5)));
$a = new Point(new Vector([1, 7, 5]));
$b = new Point(new Vector([1, 7, 5]));
$line = new LineSegment($a, $b);

$this->assertTrue($line->isDegenerate());
Expand All @@ -106,8 +106,8 @@ public function isDegenerateWithDegenerateLine()
*/
public function isDegenerateWithNondegenerateLine()
{
$a = new Point(new Vector(array(1, 7, 5)));
$b = new Point(new Vector(array(8, 7, 5)));
$a = new Point(new Vector([1, 7, 5]));
$b = new Point(new Vector([8, 7, 5]));
$line = new LineSegment($a, $b);

$this->assertFalse($line->isDegenerate());
Expand All @@ -127,11 +127,11 @@ public function isDegenerateWithNondegenerateLine()
*/
public function vectorBetweenSimplePoints()
{
$a = new Point(new Vector(array(1, 3)));
$b = new Point(new Vector(array(5, 7)));
$a = new Point(new Vector([1, 3]));
$b = new Point(new Vector([5, 7]));
$line = new LineSegment($a, $b);

$expected = new Vector(array(4, 4));
$expected = new Vector([4, 4]);
$this->assertTrue($expected->isEqual($line->vector()));
}

Expand All @@ -150,11 +150,11 @@ public function vectorBetweenSimplePoints()
*/
public function vectorOfDegenerateLineSegment()
{
$a = new Point(new Vector(array(1, 3)));
$b = new Point(new Vector(array(1, 3)));
$a = new Point(new Vector([1, 3]));
$b = new Point(new Vector([1, 3]));
$line = new LineSegment($a, $b);

$expected = new Vector(array(0, 0));
$expected = new Vector([0, 0]);
$this->assertTrue($expected->isEqual($line->vector()));
}

Expand All @@ -174,8 +174,8 @@ public function vectorOfDegenerateLineSegment()
*/
public function length()
{
$a = new Point(new Vector(array(7, 9)));
$b = new Point(new Vector(array(4, 5)));
$a = new Point(new Vector([7, 9]));
$b = new Point(new Vector([4, 5]));
$line = new LineSegment($a, $b);

$this->assertEquals(5.0, $line->length(), '', 1e-10);
Expand All @@ -197,8 +197,8 @@ public function length()
*/
public function center()
{
$a = new Point(new Vector(array(7, 9)));
$b = new Point(new Vector(array(13, 17)));
$a = new Point(new Vector([7, 9]));
$b = new Point(new Vector([13, 17]));
$line = new LineSegment($a, $b);
$centerTerms = $line->center()->terms();

Expand Down
30 changes: 15 additions & 15 deletions tests/PointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PointTest extends PHPUnit_Framework_TestCase
*/
public function vector()
{
$vector = new Vector(array(2, -1, -5));
$vector = new Vector([2, -1, -5]);
$point = new Point($vector);

$this->assertSame($vector, $point->vector());
Expand All @@ -38,7 +38,7 @@ public function vector()
*/
public function termsMaintainStructure()
{
$terms = array(3, 1.8, 'z' => -4.712);
$terms = [3, 1.8, 'z' => -4.712];
$point = new Point(new Vector($terms));

$this->assertSame($terms, $point->terms());
Expand All @@ -57,7 +57,7 @@ public function termsMaintainStructure()
*/
public function createFromTermsMaintainStructure()
{
$terms = array(3, 1.8, 'z' => -4.712);
$terms = [3, 1.8, 'z' => -4.712];
$point = Point::createFromTerms($terms);

$this->assertSame($terms, $point->terms());
Expand All @@ -73,7 +73,7 @@ public function createFromTermsMaintainStructure()
*/
public function dimensionIsCorrect()
{
$point = new Point(new Vector(array(5, 2, 1)));
$point = new Point(new Vector([5, 2, 1]));
$this->assertSame(3, $point->dimension());
}

Expand All @@ -87,8 +87,8 @@ public function dimensionIsCorrect()
*/
public function isEqualWithSamePoints()
{
$a = new Point(new Vector(array(1, 2, 3)));
$b = new Point(new Vector(array(1, 2, 3)));
$a = new Point(new Vector([1, 2, 3]));
$b = new Point(new Vector([1, 2, 3]));
$this->assertTrue($a->isEqual($b), 'Points with same terms are equal');
}

Expand All @@ -102,8 +102,8 @@ public function isEqualWithSamePoints()
*/
public function isEqualWithDifferentPoints()
{
$a = new Point(new Vector(array(1, 2, 3)));
$b = new Point(new Vector(array(9, 2, 3)));
$a = new Point(new Vector([1, 2, 3]));
$b = new Point(new Vector([9, 2, 3]));
$this->assertFalse($a->isEqual($b), 'Points with different terms are not equal');
}

Expand All @@ -117,8 +117,8 @@ public function isEqualWithDifferentPoints()
*/
public function isSameSpaceWithSameSpacePoints()
{
$a = new Point(new Vector(array(1, 2, 3)));
$b = new Point(new Vector(array(5, 7, 2)));
$a = new Point(new Vector([1, 2, 3]));
$b = new Point(new Vector([5, 7, 2]));
$this->assertTrue($a->isSameSpace($b), 'Points with same space are of the same space');
}

Expand All @@ -133,8 +133,8 @@ public function isSameSpaceWithSameSpacePoints()
*/
public function isSameSpaceWithDifferentDimensionPoints()
{
$a = new Point(new Vector(array(1, 2, 3)));
$b = new Point(new Vector(array(5, 7)));
$a = new Point(new Vector([1, 2, 3]));
$b = new Point(new Vector([5, 7]));
$this->assertFalse($a->isSameSpace($b), 'Points with different dimension are not of the same space');
}

Expand All @@ -148,8 +148,8 @@ public function isSameSpaceWithDifferentDimensionPoints()
*/
public function isSameSpaceWithDifferentlyKeyedPoints()
{
$a = new Point(new Vector(array(1, 2, 3)));
$b = new Point(new Vector(array('x' => 5, 'y' => 7, 'z' => 2)));
$a = new Point(new Vector([1, 2, 3]));
$b = new Point(new Vector(['x' => 5, 'y' => 7, 'z' => 2]));
$this->assertFalse($a->isSameSpace($b), 'Points with different keys are not of the same space');
}

Expand All @@ -164,7 +164,7 @@ public function isSameSpaceWithDifferentlyKeyedPoints()
*/
public function center()
{
$a = new Point(new Vector(array(5, 7, 9)));
$a = new Point(new Vector([5, 7, 9]));
$center = $a->center();
$this->assertSame($a->terms(), $center->terms());
}
Expand Down

0 comments on commit d5f72c4

Please sign in to comment.