Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for new version of hookable #3

Open
wants to merge 6 commits into
base: 7.1.2-erasys
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@
}
],
"require": {
"php": ">=7.1",
"sofa/hookable": "dev-7.0.1-erasys as 7.0.1",
"illuminate/database": ">=5.5"
"php": "^8.2",
"sofa/hookable": "8.0.1",
"illuminate/support": "^10.0",
"illuminate/database": "^10.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "2.3.3",
"mockery/mockery": "^1.0",
"friendsofphp/php-cs-fixer": "^2.0"
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.7",
"mockery/mockery": "^1.5",
"friendsofphp/php-cs-fixer": "^3.18.0"
},
"autoload": {
"psr-4": {
Expand All @@ -62,7 +63,7 @@
"minimum-stability": "stable",
"prefer_stable": true,
"scripts": {
"test": "phpunit && ./vendor/bin/phpcs src --standard=psr2 --report=diff --colors",
"test": "./vendor/bin/phpunit && ./vendor/bin/phpcs src --standard=psr2 --report=diff --colors",
"phpcs": "./vendor/bin/phpcs src --standard=psr2 --report=diff --colors"
}
}
}
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
Expand Down
10 changes: 5 additions & 5 deletions src/Searchable/ColumnCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function getMappings()
* @param string $key
* @return bool
*/
public function offsetExists($key)
public function offsetExists($key) : bool
{
return array_key_exists($key, $this->columns);
}
Expand All @@ -112,7 +112,7 @@ public function offsetExists($key)
* @param string $key
* @return Column
*/
public function offsetGet($key)
public function offsetGet($key) : Column
{
return $this->columns[$key];
}
Expand All @@ -124,7 +124,7 @@ public function offsetGet($key)
* @param Column $column
* @return void
*/
public function offsetSet($key, $column)
public function offsetSet($key, $column) : void
{
$this->add($column);
}
Expand All @@ -135,7 +135,7 @@ public function offsetSet($key, $column)
* @param string $key
* @return Column
*/
public function offsetUnset($key)
public function offsetUnset($key) : void
{
unset($this->columns[$key]);
}
Expand All @@ -145,7 +145,7 @@ public function offsetUnset($key)
*
* @return ArrayIterator
*/
public function getIterator()
public function getIterator() : ArrayIterator
{
return new ArrayIterator($this->columns);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Subquery.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Sofa\Eloquence;

use Illuminate\Database\Grammar;
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
Expand Down Expand Up @@ -67,7 +68,7 @@ public function getQuery()
*
* @return string
*/
public function getValue()
public function getValue(Grammar $grammar)
{
$sql = '(' . $this->query->toSql() . ')';

Expand Down
1 change: 1 addition & 0 deletions tests/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function it_joins_relations_as_strings_or_array()
$builder->rightJoinRelations(['foo', 'bar']);
$builder->joinRelations('foo', 'bar');
$builder->joinRelations(['foo', 'bar']);
$this->assertEquals(1, 1);
}

/** @test */
Expand Down
2 changes: 1 addition & 1 deletion tests/SearchableBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function it_moves_wheres_with_bindings_to_subquery_correctly()
})
->whereRaw('first_name = ?', ['outer_8'])
->whereDate('id', '=', ['inner_8'])
->where('last_name', new Expression('tkaczyk'));
->where('last_name', new Expression("tkaczyk"));

$query->get();

Expand Down
7 changes: 3 additions & 4 deletions tests/SubqueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ public function it_prints_as_aliased_query_in_parentheses()
$builder->method('getGrammar')->willReturn($grammar);
$builder->method('toSql')->willReturn('select * from "table" where id = ?');
$sub = new Subquery($builder);

$this->assertEquals('(select * from "table" where id = ?)', (string) $sub);


$this->assertEquals('select * from "table" where id = ?', (string) $sub->getQuery()->toSql());
$sub->setAlias('table_alias');

$this->assertEquals('(select * from "table" where id = ?) as "table_alias"', (string) $sub);
$this->assertEquals('(select * from "table" where id = ?) as "table_alias"', $sub->getValue($grammar));
$this->assertEquals('table_alias', $sub->getAlias());
}

Expand Down