Skip to content

Commit

Permalink
Drop PHP 5.6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Mar 13, 2016
1 parent a05317c commit dfece08
Show file tree
Hide file tree
Showing 49 changed files with 436 additions and 359 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Expand Up @@ -3,7 +3,6 @@ sudo: false
language: php

php:
- 5.6
- 7.0
- hhvm

Expand All @@ -19,5 +18,5 @@ script:
- mkdir -p build/logs
- phpunit --coverage-clover build/logs/clover.xml

after_script:
- sh -c 'if [ "$TRAVIS_PHP_VERSION" = "5.5" ]; then php vendor/bin/coveralls -v; fi;'
after_success:
- sh -c 'if [ "$TRAVIS_PHP_VERSION" = "7.0" ]; then php vendor/bin/coveralls -v; fi;'
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -2138,7 +2138,7 @@ $nodes = ActiveRecord\get_model('nodes');

## Requirements

The package requires PHP 5.5 or later and the [PDO extension](http://php.net/manual/en/intro.pdo.php).
The package requires PHP 7.0 or later and the [PDO extension](http://php.net/manual/en/intro.pdo.php).



Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -21,7 +21,7 @@
"minimum-stability": "dev",

"require": {
"php": ">=5.6.0",
"php": "^7.0",
"ext-pdo": "*",
"icanboogie/prototype": "^2.3",
"icanboogie/inflector": "^1.4",
Expand Down
10 changes: 5 additions & 5 deletions lib/ActiveRecord.php
Expand Up @@ -85,7 +85,7 @@ public function __construct($model = null)
* Properties whose value are instances of the {@link ActiveRecord} class are removed from the
* exported properties.
*/
public function __sleep()
public function __sleep(): array
{
$properties = parent::__sleep();

Expand All @@ -108,7 +108,7 @@ public function __sleep()
*
* @return array
*/
public function __debugInfo()
public function __debugInfo(): array
{
$array = (array) $this;

Expand All @@ -122,7 +122,7 @@ public function __debugInfo()
*
* @return Model
*/
protected function get_model()
protected function get_model(): Model
{
return $this->model
?: $this->model = ActiveRecord\get_model($this->model_id);
Expand Down Expand Up @@ -200,7 +200,7 @@ public function save()
*
* @return array The altered persistent properties
*/
protected function alter_persistent_properties(array $properties, Model $model)
protected function alter_persistent_properties(array $properties, Model $model): array
{
$schema = $model->extended_schema;

Expand Down Expand Up @@ -242,7 +242,7 @@ protected function update_primary_key($primary_key)
*
* @throws \Exception in attempt to delete a record from a model which primary key is empty.
*/
public function delete()
public function delete(): bool
{
$model = $this->model;
$primary = $model->primary;
Expand Down
4 changes: 2 additions & 2 deletions lib/ActiveRecord/ActiveRecordCache.php
Expand Up @@ -32,14 +32,14 @@ public function store(ActiveRecord $record);
*
* @return ActiveRecord|null
*/
public function retrieve($key);
public function retrieve(int $key);

/**
* Eliminates an {@link ActiveRecord} instance from the cache.
*
* @param int $key
*/
public function eliminate($key);
public function eliminate(int $key);

/**
* Clears the cache.
Expand Down
12 changes: 6 additions & 6 deletions lib/ActiveRecord/ActiveRecordClassNotValid.php
Expand Up @@ -25,25 +25,25 @@ class ActiveRecordClassNotValid extends \LogicException implements Exception
use AccessorTrait;

/**
* @var string
* @var mixed
*/
private $class;

/**
* @return string
* @return mixed
*/
protected function get_class()
{
return $this->class;
}

/**
* @param string $class
* @param mixed $class
* @param string|null $message
* @param int $code
* @param \Exception|null $previous
*/
public function __construct($class, $message = null, $code = 500, \Exception $previous = null)
public function __construct($class, string $message = null, int $code = 500, \Exception $previous = null)
{
$this->class = $class;

Expand All @@ -53,11 +53,11 @@ public function __construct($class, $message = null, $code = 500, \Exception $pr
/**
* Formats exception message.
*
* @param string $class
* @param mixed $class
*
* @return string
*/
protected function format_message($class)
protected function format_message($class): string
{
return format("ActiveRecord class is not valid: %class", [

Expand Down
6 changes: 4 additions & 2 deletions lib/ActiveRecord/BelongsToRelation.php
Expand Up @@ -48,6 +48,8 @@ public function __construct(Model $parent, $related, array $options = [])

/**
* @inheritdoc
*
* @return ActiveRecord|null
*/
public function __invoke(ActiveRecord $record)
{
Expand All @@ -66,7 +68,7 @@ public function __invoke(ActiveRecord $record)
*
* @inheritdoc
*/
protected function alter_prototype(Prototype $prototype, $property)
protected function alter_prototype(Prototype $prototype, string $property)
{
parent::alter_prototype($prototype, $property);

Expand All @@ -80,7 +82,7 @@ protected function alter_prototype(Prototype $prototype, $property)
/**
* @inheritdoc
*/
protected function resolve_property_name($related)
protected function resolve_property_name($related): string
{
return singularize(parent::resolve_property_name($related));
}
Expand Down
51 changes: 25 additions & 26 deletions lib/ActiveRecord/Connection.php
Expand Up @@ -45,7 +45,7 @@ class Connection extends \PDO implements Driver
/**
* @return string
*/
protected function get_id()
protected function get_id(): string
{
return $this->id;
}
Expand All @@ -64,7 +64,7 @@ protected function get_id()
/**
* @return string
*/
protected function get_table_name_prefix()
protected function get_table_name_prefix(): string
{
return $this->table_name_prefix;
}
Expand All @@ -79,7 +79,7 @@ protected function get_table_name_prefix()
/**
* @return string
*/
protected function get_charset()
protected function get_charset(): string
{
return $this->charset;
}
Expand All @@ -94,7 +94,7 @@ protected function get_charset()
/**
* @return string
*/
protected function get_collate()
protected function get_collate(): string
{
return $this->collate;
}
Expand All @@ -109,7 +109,7 @@ protected function get_collate()
/**
* @return string
*/
protected function get_timezone()
protected function get_timezone(): string
{
return $this->timezone;
}
Expand All @@ -124,7 +124,7 @@ protected function get_timezone()
/**
* @return string
*/
protected function get_driver_name()
protected function get_driver_name(): string
{
return $this->driver_name;
}
Expand All @@ -137,7 +137,7 @@ protected function get_driver_name()
/**
* @return Driver
*/
protected function lazy_get_driver()
protected function lazy_get_driver(): Driver
{
return $this->resolve_driver($this->driver_name);
}
Expand Down Expand Up @@ -170,7 +170,7 @@ protected function lazy_get_driver()
* @param string $password
* @param array $options
*/
public function __construct($dsn, $username = null, $password = null, $options = [])
public function __construct(string $dsn, string $username = null, string $password = null, array $options = [])
{
unset($this->driver);

Expand All @@ -186,11 +186,13 @@ public function __construct($dsn, $username = null, $password = null, $options =
/**
* Alias to {@link query}.
*
* @param array ...$args
*
* @return Statement
*/
public function __invoke()
public function __invoke(...$args): Statement
{
return call_user_func_array([ $this, 'query' ], func_get_args());
return $this->query(...$args);
}

/**
Expand All @@ -200,7 +202,7 @@ public function __invoke()
*
* @return string
*/
protected function resolve_driver_name($dsn)
protected function resolve_driver_name(string $dsn): string
{
return explode(':', $dsn, 2)[0];
}
Expand All @@ -214,7 +216,7 @@ protected function resolve_driver_name($dsn)
*
* @throws DriverNotDefined
*/
protected function resolve_driver_class($driver_name)
protected function resolve_driver_class(string $driver_name): string
{
if (empty(self::$drivers_mapping[$driver_name]))
{
Expand All @@ -231,7 +233,7 @@ protected function resolve_driver_class($driver_name)
*
* @return Driver
*/
protected function resolve_driver($driver_name)
protected function resolve_driver(string $driver_name): Driver
{
$driver_class = $this->resolve_driver_class($driver_name);

Expand Down Expand Up @@ -298,10 +300,7 @@ protected function after_connection()
* Overrides the method to resolve the statement before it is prepared, then set its fetch
* mode and connection.
*
* @param string $statement Query statement.
* @param array $options
*
* @return Statement The prepared statement.
* @inheritdoc
*
* @throws StatementNotValid if the statement cannot be prepared.
*/
Expand All @@ -325,7 +324,7 @@ public function prepare($statement, $options = [])
{
$mode = (array) $options['mode'];

call_user_func_array([ $statement, 'setFetchMode' ], $mode);
$statement->mode(...$mode);
}

return $statement;
Expand All @@ -339,7 +338,7 @@ public function prepare($statement, $options = [])
*
* @return Statement
*/
public function query($statement, array $args = [], array $options = [])
public function query(string $statement, array $args = [], array $options = []): Statement
{
$statement = $this->prepare($statement, $options);
$statement->execute($args);
Expand Down Expand Up @@ -392,7 +391,7 @@ public function exec($statement)
*
* @return string The resolved statement.
*/
public function resolve_statement($statement)
public function resolve_statement(string $statement): string
{
return strtr($statement, [

Expand Down Expand Up @@ -438,7 +437,7 @@ public function quote_identifier($identifier)
*
* @codeCoverageIgnore
*/
public function cast_value($value, $type = null)
public function cast_value($value, string $type = null)
{
return $this->driver->cast_value($value, $type);
}
Expand All @@ -448,7 +447,7 @@ public function cast_value($value, $type = null)
*
* @codeCoverageIgnore
*/
public function render_column(SchemaColumn $column)
public function render_column(SchemaColumn $column): string
{
return $this->driver->render_column($column);
}
Expand All @@ -458,7 +457,7 @@ public function render_column(SchemaColumn $column)
*
* @codeCoverageIgnore
*/
public function create_table($unprefixed_name, Schema $schema)
public function create_table(string $unprefixed_name, Schema $schema)
{
$this->driver->create_table($unprefixed_name, $schema);
}
Expand All @@ -468,7 +467,7 @@ public function create_table($unprefixed_name, Schema $schema)
*
* @codeCoverageIgnore
*/
public function create_indexes($unprefixed_table_name, Schema $schema)
public function create_indexes(string $unprefixed_table_name, Schema $schema)
{
$this->driver->create_indexes($unprefixed_table_name, $schema);
}
Expand All @@ -478,7 +477,7 @@ public function create_indexes($unprefixed_table_name, Schema $schema)
*
* @codeCoverageIgnore
*/
public function create_unique_indexes($unprefixed_table_name, Schema $schema)
public function create_unique_indexes(string $unprefixed_table_name, Schema $schema)
{
$this->driver->create_unique_indexes($unprefixed_table_name, $schema);
}
Expand All @@ -488,7 +487,7 @@ public function create_unique_indexes($unprefixed_table_name, Schema $schema)
*
* @codeCoverageIgnore
*/
public function table_exists($unprefixed_name)
public function table_exists(string $unprefixed_name): bool
{
return $this->driver->table_exists($unprefixed_name);
}
Expand Down

0 comments on commit dfece08

Please sign in to comment.