Skip to content

Commit

Permalink
Drop PHP 5.5 support #13
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Nov 6, 2016
1 parent c78cd0c commit 54735f1
Show file tree
Hide file tree
Showing 15 changed files with 119 additions and 94 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ cache:
language: php

php:
- 5.5
- 5.6
- 7.0
- 7.1
Expand All @@ -19,12 +18,12 @@ matrix:
- php: hhvm

before_script:
- if [[ $TRAVIS_PHP_VERSION != "5.5" ]]; then composer install --prefer-dist; fi
- if [[ $TRAVIS_PHP_VERSION = "5.5" ]]; then composer require satooshi/php-coveralls --prefer-dist; fi
- if [[ $TRAVIS_PHP_VERSION != "5.6" ]]; then composer install --prefer-dist; fi
- if [[ $TRAVIS_PHP_VERSION = "5.6" ]]; then composer require satooshi/php-coveralls --prefer-dist; fi

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

after_success:
- if [[ "$TRAVIS_PHP_VERSION" = "5.5" ]]; then php vendor/bin/coveralls -v; fi
- if [[ "$TRAVIS_PHP_VERSION" = "5.6" ]]; then php vendor/bin/coveralls -v; fi
54 changes: 27 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Active Record

[![Release](https://img.shields.io/packagist/v/ICanBoogie/activerecord.svg)](https://packagist.org/packages/icanboogie/activerecord)
[![Build Status](https://img.shields.io/travis/ICanBoogie/ActiveRecord.svg)](http://travis-ci.org/ICanBoogie/ActiveRecord)
[![Build Status](https://img.shields.io/travis/ICanBoogie/ActiveRecord/4.0.svg)](http://travis-ci.org/ICanBoogie/ActiveRecord)
[![HHVM](https://img.shields.io/hhvm/icanboogie/activerecord.svg)](http://hhvm.h4cc.de/package/icanboogie/activerecord)
[![Code Quality](https://img.shields.io/scrutinizer/g/ICanBoogie/ActiveRecord.svg)](https://scrutinizer-ci.com/g/ICanBoogie/ActiveRecord)
[![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/ActiveRecord.svg)](https://coveralls.io/r/ICanBoogie/ActiveRecord)
[![Code Quality](https://img.shields.io/scrutinizer/g/ICanBoogie/ActiveRecord/4.0.svg)](https://scrutinizer-ci.com/g/ICanBoogie/ActiveRecord)
[![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/ActiveRecord/4.0.svg)](https://coveralls.io/r/ICanBoogie/ActiveRecord)
[![Packagist](https://img.shields.io/packagist/dt/icanboogie/activerecord.svg)](https://packagist.org/packages/icanboogie/activerecord)

__Connections__, __models__ and __active records__ are the foundations of everything that concerns
Expand Down Expand Up @@ -2432,7 +2432,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 5.6 or later and the [PDO extension](http://php.net/manual/en/intro.pdo.php).



Expand Down Expand Up @@ -2483,8 +2483,8 @@ clean` command.

The package is continuously tested by [Travis CI](http://about.travis-ci.org/).

[![Build Status](https://img.shields.io/travis/ICanBoogie/ActiveRecord.svg)](https://travis-ci.org/ICanBoogie/ActiveRecord)
[![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/ActiveRecord.svg)](https://coveralls.io/r/ICanBoogie/ActiveRecord)
[![Build Status](https://img.shields.io/travis/ICanBoogie/ActiveRecord/4.0.svg)](https://travis-ci.org/ICanBoogie/ActiveRecord)
[![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/ActiveRecord/4.0.svg)](https://coveralls.io/r/ICanBoogie/ActiveRecord)



Expand All @@ -2498,27 +2498,27 @@ The package is continuously tested by [Travis CI](http://about.travis-ci.org/).



[Connection]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.Connection.html
[ConnectionAlreadyEstablished]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.ConnectionAlreadyEstablished.html
[ConnectionNotDefined]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.ConnectionNotDefined.html
[ConnectionNotEstablished]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.ConnectionNotEstablished.html
[ConnectionCollection]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.ConnectionCollection.html
[CreatedAtProperty]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.Property.CreatedAtProperty.html
[DateTimeProperty]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.Property.DateTimeProperty.html
[Model]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.Model.html
[ModelAlreadyInstantiated]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.ModelAlreadyInstantiated.html
[ModelNotDefined]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.ModelNotDefined.html
[ModelCollection]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.ModelCollection.html
[Query]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.Query.html
[RecordNotFound]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.RecordNotFound.html
[RecordNotValid]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.RecordNotValid.html
[RelationNotDefined]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.RelationNotDefined.html
[RuntimeActiveRecordCache]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.ActiveRecordCache.RuntimeActiveRecordCache.html
[ScopeNotDefined]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.ScopeNotDefined.html
[StatementInvocationFailed]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.StatementInvocationFailed.html
[StatementNotValid]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.StatementNotValid.html
[UnableToSetFetchMode]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.UnableToSetFetchMode.html
[UpdatedAtProperty]: http://api.icanboogie.org/activerecord/3.0/class-ICanBoogie.ActiveRecord.Property.UpdatedAtProperty.html
[Connection]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.Connection.html
[ConnectionAlreadyEstablished]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.ConnectionAlreadyEstablished.html
[ConnectionNotDefined]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.ConnectionNotDefined.html
[ConnectionNotEstablished]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.ConnectionNotEstablished.html
[ConnectionCollection]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.ConnectionCollection.html
[CreatedAtProperty]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.Property.CreatedAtProperty.html
[DateTimeProperty]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.Property.DateTimeProperty.html
[Model]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.Model.html
[ModelAlreadyInstantiated]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.ModelAlreadyInstantiated.html
[ModelNotDefined]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.ModelNotDefined.html
[ModelCollection]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.ModelCollection.html
[Query]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.Query.html
[RecordNotFound]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.RecordNotFound.html
[RecordNotValid]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.RecordNotValid.html
[RelationNotDefined]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.RelationNotDefined.html
[RuntimeActiveRecordCache]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.ActiveRecordCache.RuntimeActiveRecordCache.html
[ScopeNotDefined]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.ScopeNotDefined.html
[StatementInvocationFailed]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.StatementInvocationFailed.html
[StatementNotValid]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.StatementNotValid.html
[UnableToSetFetchMode]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.UnableToSetFetchMode.html
[UpdatedAtProperty]: http://api.icanboogie.org/activerecord/4.0/class-ICanBoogie.ActiveRecord.Property.UpdatedAtProperty.html
[DateTime]: http://api.icanboogie.org/datetime/1.2/class-ICanBoogie.DateTime.html
[ValidationErrors]: http://api.icanboogie.org/validate/latest/class-ICanBoogie.Validate.ValidationErrors.html
[icanboogie/bind-activerecord]: https://github.com/ICanBoogie/bind-activerecord
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"minimum-stability": "dev",

"require": {
"php": ">=5.5.0",
"php": ">=5.6.0",
"ext-pdo": "*",
"icanboogie/prototype": "^2.3",
"icanboogie/prototype": "^3.0",
"icanboogie/inflector": "^1.4",
"icanboogie/datetime": "^1.2",
"icanboogie/validate": "dev-master"
Expand Down
4 changes: 3 additions & 1 deletion lib/ActiveRecord/ActiveRecordClassNotValid.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

use ICanBoogie\Accessor\AccessorTrait;

use function ICanBoogie\format;

/**
* Exception thrown when the ActiveRecord class is not valid.
*
Expand Down Expand Up @@ -57,7 +59,7 @@ public function __construct($class, $message = null, $code = 500, \Exception $pr
*/
protected function format_message($class)
{
return \ICanBoogie\format("ActiveRecord class is not valid: %class", [
return format("ActiveRecord class is not valid: %class", [

'class' => $class

Expand Down
4 changes: 3 additions & 1 deletion lib/ActiveRecord/BelongsToRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use ICanBoogie\ActiveRecord;
use ICanBoogie\Prototype;

use function ICanBoogie\singularize;

/**
* Representation of the one-to-one relation.
*/
Expand Down Expand Up @@ -80,6 +82,6 @@ protected function alter_prototype(Prototype $prototype, $property)
*/
protected function resolve_property_name($related)
{
return \ICanBoogie\singularize(parent::resolve_property_name($related));
return singularize(parent::resolve_property_name($related));
}
}
8 changes: 5 additions & 3 deletions lib/ActiveRecord/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
return call_user_func_array([ $this, 'query' ], func_get_args());
return $this->query(...$args);
}

/**
Expand Down Expand Up @@ -325,7 +327,7 @@ public function prepare($statement, $options = [])
{
$mode = (array) $options['mode'];

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

return $statement;
Expand Down
4 changes: 3 additions & 1 deletion lib/ActiveRecord/ConnectionAlreadyEstablished.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

use ICanBoogie\Accessor\AccessorTrait;

use function ICanBoogie\format;

/**
* Exception thrown in attempt to set the definition of an already established connection.
*
Expand Down Expand Up @@ -56,7 +58,7 @@ public function __construct($id, $code = 500, \Exception $previous = null)
*/
protected function format_message($id)
{
return \ICanBoogie\format("Connection already established: %id.", [
return format("Connection already established: %id.", [

'id' => $id

Expand Down
4 changes: 3 additions & 1 deletion lib/ActiveRecord/ConnectionNotDefined.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

use ICanBoogie\Accessor\AccessorTrait;

use function ICanBoogie\format;

/**
* Exception thrown in attempt to obtain a connection that is not defined.
*
Expand Down Expand Up @@ -53,7 +55,7 @@ public function __construct($id, $code = 500, \Exception $previous = null)
*/
protected function format_message($id)
{
return \ICanBoogie\format("Connection not defined: %id.", [
return format("Connection not defined: %id.", [

'id' => $id

Expand Down
4 changes: 3 additions & 1 deletion lib/ActiveRecord/HasManyRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

use ICanBoogie\ActiveRecord;

use function ICanBoogie\pluralize;

/**
* Representation of the one-to-many relation.
*/
Expand All @@ -34,6 +36,6 @@ public function __invoke(ActiveRecord $record)

protected function resolve_property_name($related)
{
return \ICanBoogie\pluralize(parent::resolve_property_name($related));
return pluralize(parent::resolve_property_name($related));
}
}
6 changes: 5 additions & 1 deletion lib/ActiveRecord/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class Helpers
*/
static public function __callStatic($name, array $arguments)
{
return call_user_func_array(self::$mapping[$name], $arguments);
$method = self::$mapping[$name];

return $method(...$arguments);
}

/**
Expand All @@ -44,6 +46,8 @@ static public function __callStatic($name, array $arguments)
* @param callable $callback Callback.
*
* @throws \RuntimeException is attempt to patch an undefined function.
*
* @return callable
*/
static public function patch($name, $callback)
{
Expand Down
25 changes: 20 additions & 5 deletions lib/ActiveRecord/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @method ActiveRecord one() one() The method is forwarded to {@link Query::one}.
* @method ActiveRecord new() new(array $properties = []) Instantiate a new record.
*
* @method Model belongs_to() belongs_to($definition) Add a _belongs_to_ relation.
* @method Model belongs_to() belongs_to(...$args) Adds a _belongs_to_ relation.
* @method Model has_many() has_many($related, $options = []) Adds a _has_many_ relation.
*
* @property-read Model|null $parent Parent model.
Expand Down Expand Up @@ -163,6 +163,21 @@ public function __construct(ModelCollection $models, array $attributes)
$this->resolve_relations();
}

// @codeCoverageIgnoreStart
public function __debugInfo()
{
return [

'id' => $this->id,
'name' => "$this->name ($this->unprefixed_name)",
'parent' => $this->parent ? $this->parent->id . " of " . get_class($this->parent) : null,
'parent_model' => $this->parent_model ? $this->parent_model->id . " of " . get_class($this->parent_model) : null,
'relations' => $this->relations

];
}
// @codeCoverageIgnoreEnd

/**
* Resolves constructor attributes.
*
Expand Down Expand Up @@ -259,7 +274,7 @@ public function __call($method, $arguments)
{
if ($method == 'new')
{
return call_user_func_array([ $this, 'new_record' ], $arguments);
return $this->new_record(...$arguments);
}

if (is_callable([ Query::class, $method ])
Expand All @@ -268,12 +283,12 @@ public function __call($method, $arguments)
{
$query = new Query($this);

return call_user_func_array([ $query, $method ], $arguments);
return $query->$method(...$arguments);
}

if (is_callable([ RelationCollection::class, $method ]))
{
return call_user_func_array([ $this->relations, $method ], $arguments);
return $this->relations->$method(...$arguments);
}

return parent::__call($method, $arguments);
Expand Down Expand Up @@ -542,7 +557,7 @@ public function scope($scope_name, array $scope_args = [])
{
try
{
return call_user_func_array([ $this, 'scope_' . $scope_name ], $scope_args);
return $this->{ 'scope_' . $scope_name}(...$scope_args);
}
catch (MethodNotDefined $e)
{
Expand Down

0 comments on commit 54735f1

Please sign in to comment.