Skip to content

Commit

Permalink
Merge pull request #16 from oat-sa/php7
Browse files Browse the repository at this point in the history
First trial PHP7. All pass but seg faults and mm_heap corrupted.
  • Loading branch information
Jérôme Bogaerts committed Oct 11, 2015
2 parents 5558601 + 307af36 commit 59100fc
Show file tree
Hide file tree
Showing 274 changed files with 3,510 additions and 3,509 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ php:
- 5.4
- 5.5
- 5.6
- 7

before_script:
- composer install --no-interaction
- composer self-update && composer install --no-interaction

script:
- mkdir -p build/logs
- ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml

after_script:
- ./vendor/bin/coveralls -v
- ./vendor/bin/coveralls -v
12 changes: 6 additions & 6 deletions src/qtism/common/collections/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

namespace qtism\common\collections;

use qtism\common\datatypes\File;
use qtism\common\datatypes\Boolean;
use qtism\common\datatypes\String;
use qtism\common\datatypes\QtiFile;
use qtism\common\datatypes\QtiBoolean;
use qtism\common\datatypes\QtiString;
use qtism\data\state\ValueCollection;
use qtism\common\enums\Cardinality;
use qtism\common\collections\AbstractCollection;
Expand Down Expand Up @@ -241,12 +241,12 @@ public function __toString()

if (is_null($d) === true) {
$strings[] = 'NULL';
} elseif ($d instanceof String) {
} elseif ($d instanceof QtiString) {
$strings[] = "'${d}'";
} elseif ($d instanceof Boolean) {
} elseif ($d instanceof QtiBoolean) {
// PHP boolean primitive type.
$strings[] = ($d->getValue() === true) ? 'true' : 'false';
} elseif ($d instanceof File) {
} elseif ($d instanceof QtiFile) {
$strings[] = $d->getFilename();
} else {
// Other PHP primitive/object type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
class Boolean extends Scalar
class QtiBoolean extends QtiScalar
{
/**
* Check whether or not the intrinsic $value is a PHP boolean.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
class Coords extends IntegerCollection implements QtiDatatype
class QtiCoords extends IntegerCollection implements QtiDatatype
{
/**
* A value from the Shape enumeration.
Expand All @@ -54,28 +54,28 @@ public function __construct($shape, array $coords = array())
$this->setShape($shape);

switch ($this->getShape()) {
case Shape::DEF:
case QtiShape::DEF:
if (count($this->getDataPlaceHolder()) > 0) {
$msg = "No coordinates should be given when the default shape is used.";
throw new InvalidArgumentException($msg);
}
break;

case Shape::RECT:
case QtiShape::RECT:
if (count($this->getDataPlaceHolder()) != 4) {
$msg = "The rectangle coordinates must be composed by 4 values (x1, y1, x2, y2).";
throw new InvalidArgumentException($msg);
}
break;

case Shape::CIRCLE:
case QtiShape::CIRCLE:
if (count($this->getDataPlaceHolder()) != 3) {
$msg = "The circle coordinates must be composed by 3 values (x, y, r).";
throw new InvalidArgumentException($msg);
}
break;

case Shape::POLY:
case QtiShape::POLY:
if (count($this->getDataPlaceHolder()) % 2 > 0) {
$msg = "The polygon coordinates must be composed by a pair amount of values (x1, y1, x2, y2, ...).";
throw new InvalidArgumentException($msg);
Expand All @@ -92,7 +92,7 @@ public function __construct($shape, array $coords = array())
*/
protected function setShape($shape)
{
if (in_array($shape, Shape::asArray())) {
if (in_array($shape, QtiShape::asArray())) {
$this->shape = $shape;
} else {
$msg = "The shape argument must be a value from the Shape enumeration except 'default', '" . $shape . "' given.";
Expand All @@ -117,13 +117,13 @@ public function getShape()
* @param Point $point A Point object.
* @return boolean
*/
public function inside(Point $point)
public function inside(QtiPoint $point)
{
if ($this->getShape() === Shape::DEF) {
if ($this->getShape() === QtiShape::DEF) {
return true;
} elseif ($this->getShape() === Shape::RECT) {
} elseif ($this->getShape() === QtiShape::RECT) {
return $point->getX() >= $this[0] && $point->getX() <= $this[2] && $point->getY() >= $this[1] && $point->getY() <= $this[3];
} elseif ($this->getShape() === Shape::CIRCLE) {
} elseif ($this->getShape() === QtiShape::CIRCLE) {
return pow($point->getX() - $this[0], 2) + pow($point->getY() - $this[1], 2) < pow($this[2], 2);
} else {
// we consider it is a polygon.
Expand Down Expand Up @@ -187,7 +187,7 @@ public function __toString()
*/
public function equals($obj)
{
return $obj instanceof Coords && $this->getShape() === $obj->getShape() && $this->getArrayCopy() == $obj->getArrayCopy();
return $obj instanceof QtiCoords && $this->getShape() === $obj->getShape() && $this->getArrayCopy() == $obj->getArrayCopy();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
class DirectedPair extends Pair
class QtiDirectedPair extends QtiPair
{
/**
* Whether or not $obj is equal to $this. Two DirectedPair objects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
class Duration implements QtiDatatype
class QtiDuration implements QtiDatatype
{
/**
* Internally, the Duration class always
Expand Down Expand Up @@ -112,7 +112,7 @@ public function __construct($intervalSpec)
*/
public static function createFromDateInterval(DateInterval $interval)
{
$duration = new Duration('PT0S');
$duration = new QtiDuration('PT0S');
$duration->setInterval($interval);

return $duration;
Expand Down Expand Up @@ -271,7 +271,7 @@ public function equals($obj)
* @param \qtism\common\datatypes\Duration $duration A Duration object to compare with this one.
* @return boolean
*/
public function shorterThan(Duration $duration)
public function shorterThan(QtiDuration $duration)
{
return $this->getSeconds(true) < $duration->getSeconds(true);
}
Expand All @@ -283,7 +283,7 @@ public function shorterThan(Duration $duration)
* @param \qtism\common\datatypes\Duration $duration A Duration object to compare with this one.
* @return boolean
*/
public function longerThanOrEquals(Duration $duration)
public function longerThanOrEquals(QtiDuration $duration)
{
return $this->getSeconds(true) >= $duration->getSeconds(true);
}
Expand All @@ -300,7 +300,7 @@ public function add($duration)
$d1 = $this->refDate;
$d2 = clone $d1;

if ($duration instanceof Duration) {
if ($duration instanceof QtiDuration) {
$toAdd = $duration;
} elseif ($duration instanceof DateInterval) {
$toAdd = self::createFromDateInterval($duration);
Expand All @@ -321,7 +321,7 @@ public function add($duration)
*
* For instance P2S - P1S = P1S
*/
public function sub(Duration $duration)
public function sub(QtiDuration $duration)
{
if ($duration->longerThanOrEquals($this) === true) {
$this->setInterval(new DateInterval('PT0S'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
interface File extends QtiDatatype
interface QtiFile extends QtiDatatype
{
/**
* Get the sequence of bytes composing the file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
class Float extends Scalar
class QtiFloat extends QtiScalar
{
/**
* Check whether or not $value is a Float object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
class Identifier extends String
class QtiIdentifier extends QtiString
{
/**
* Checks whether or not $value is a string value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
class IntOrIdentifier extends Scalar
class QtiIntOrIdentifier extends QtiScalar
{
/**
* Checks whether or not $value is a valid integer or string to be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
class Integer extends Scalar
class QtiInteger extends QtiScalar
{
/**
* Checks whether or not $value is an integer compliant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
class Pair implements QtiDatatype
class QtiPair implements QtiDatatype
{
/**
* The first identifier of the Pair.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
class Point implements QtiDatatype
class QtiPoint implements QtiDatatype
{
/**
* The position on the x-axis.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
abstract class Scalar implements QtiDatatype
abstract class QtiScalar implements QtiDatatype
{
/**
* The value of the Scalar object.
Expand Down Expand Up @@ -88,7 +88,7 @@ public function getValue()
*/
public function equals($obj)
{
if ($obj instanceof Scalar) {
if ($obj instanceof QtiScalar) {
return $obj->getValue() === $this->getValue();
} else {
return $this->getValue() === $obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
class Shape implements Enumeration
class QtiShape implements Enumeration
{
/**
* Note: Corresponds to QTI shape::default. Unfortunately, 'default' is a reserved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
class String extends Scalar
class QtiString extends QtiScalar
{
/**
* Checks whether or not $value is a valid string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
class Uri extends String
class QtiUri extends QtiString
{
/**
* Checks whether or not $value is a string.
Expand Down
4 changes: 2 additions & 2 deletions src/qtism/common/datatypes/files/FileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace qtism\common\datatypes\files;

use qtism\common\datatypes\File;
use qtism\common\datatypes\QtiFile;

/**
* The File Management System of QTISM is an augmented implementation
Expand Down Expand Up @@ -76,5 +76,5 @@ public function retrieve($identifier);
* @param \qtism\common\datatypes\File $file A persistent file to be deleted gracefully.
* @throws \qtism\common\datatypes\files\FileManagerException
*/
public function delete(File $file);
public function delete(QtiFile $file);
}
6 changes: 3 additions & 3 deletions src/qtism/common/datatypes/files/FileSystemFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

use qtism\common\enums\BaseType;
use qtism\common\enums\Cardinality;
use qtism\common\datatypes\File;
use qtism\common\datatypes\QtiFile;
use \RuntimeException;

/**
Expand All @@ -34,7 +34,7 @@
* @author Jérôme Bogaerts <[email protected]>
*
*/
class FileSystemFile implements File
class FileSystemFile implements QtiFile
{
/**
* The path to the file on the persistent storage.
Expand Down Expand Up @@ -344,7 +344,7 @@ public function hasFilename()
*/
public function equals($obj)
{
if ($obj instanceof File) {
if ($obj instanceof QtiFile) {
if ($this->getFilename() !== $obj->getFilename()) {
return false;
} elseif ($this->getMimeType() !== $obj->getMimeType()) {
Expand Down
4 changes: 2 additions & 2 deletions src/qtism/common/datatypes/files/FileSystemFileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace qtism\common\datatypes\files;

use qtism\common\datatypes\File;
use qtism\common\datatypes\QtiFile;
use \RuntimeException;

/**
Expand Down Expand Up @@ -127,7 +127,7 @@ public function retrieve($identifier)
*
* @throws \qtism\common\datatypes\files\FileManagerException
*/
public function delete(File $file)
public function delete(QtiFile $file)
{
$deletion = @unlink($file->getPath());
if ($deletion === false) {
Expand Down
6 changes: 3 additions & 3 deletions src/qtism/data/TimeLimits.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace qtism\data;

use qtism\common\datatypes\Duration;
use qtism\common\datatypes\QtiDuration;
use \InvalidArgumentException;

/**
Expand Down Expand Up @@ -116,7 +116,7 @@ public function hasMinTime()
*
* @param \qtism\common\datatypes\Duration $minTime A Duration object or null if unlimited.
*/
public function setMinTime(Duration $minTime = null)
public function setMinTime(QtiDuration $minTime = null)
{
// Prevent to get 0s durations stored.
if (is_null($minTime) === false && $minTime->getSeconds(true) === 0) {
Expand Down Expand Up @@ -151,7 +151,7 @@ public function hasMaxTime()
*
* @param \qtism\common\datatypes\Duration $maxTime A duration object or null if unlimited.
*/
public function setMaxTime(Duration $maxTime = null)
public function setMaxTime(QtiDuration $maxTime = null)
{
// Prevent to get 0s durations stored.
if (is_null($maxTime) === false && $maxTime->getSeconds(true) === 0) {
Expand Down
Loading

0 comments on commit 59100fc

Please sign in to comment.