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

upgrade to laravel 8 #26

Merged
merged 45 commits into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e59b50a
Upgraded laravel to ^8.0
tschallacka Apr 25, 2021
4fa71da
Updated composer.json to ignore eclipse files
tschallacka Apr 25, 2021
d570980
Updated requirement to php 7.4
tschallacka Apr 25, 2021
ad9f2ea
Removed Storm QueryBuilder as typehint, as this invalidates the metho…
tschallacka Apr 25, 2021
ae9c706
Removed typehint for setKeySForSaveQuery as that invalidates the pare…
tschallacka Apr 25, 2021
bb35db7
Fixed import path, should have been Query instead of Eloquent
tschallacka Apr 25, 2021
850b42c
Fixed import path, should have been Query instead of Eloquent
tschallacka Apr 25, 2021
8352939
Added default value null to to make the method signature compatible …
tschallacka Apr 25, 2021
c146ccf
Changed Exception to Throwable to make the methods compatible with pa…
tschallacka Apr 25, 2021
639e6fe
Transport manager was changed in Mail Manager in laravel 7.
tschallacka Apr 25, 2021
b951da4
Added a todo note
tschallacka Apr 25, 2021
d5ec7d9
Changed the use of the encrypter variable as it is a static variable …
tschallacka Apr 25, 2021
db15860
added a name to the Mailer constructor
tschallacka Apr 25, 2021
c0bd766
Removed variable
tschallacka Apr 25, 2021
bc8ac3e
Resolving merge conficts
tschallacka Apr 25, 2021
18db743
Resolving merge conficts
tschallacka Apr 25, 2021
2434782
Merge branch 'wip/1.2' into 1.2
tschallacka Apr 25, 2021
4999eda
Set php version to 7.3 as laravel 8 only requires that.
tschallacka Apr 26, 2021
a10f1a8
Fixed code style issues
tschallacka Apr 26, 2021
1161361
Merge branch '1.2' of https://github.com/tschallacka/storm into 1.2
tschallacka Apr 26, 2021
6286f15
Removed backports of compileUpsert in SQL grammars
tschallacka Apr 26, 2021
fe6b883
Removed phpunit result cache and added it to the gitignore
tschallacka Apr 26, 2021
2be2479
Fixed unit tests, as the compare compiled queries were missing a semi…
tschallacka Apr 26, 2021
8f288e4
Removed php 7.2 runner from github workflow
tschallacka Apr 26, 2021
421d088
Added a unit test for version.yaml interpretation
tschallacka Apr 26, 2021
9650316
bring back the editorconfig. removed by accident
tschallacka Apr 26, 2021
e81f03b
Update .editorconfig
LukeTowers Apr 29, 2021
d646c0b
Removed Yaml version test as per https://github.com/wintercms/storm/p…
tschallacka Apr 29, 2021
f7d1a37
Removing 7.3 support as per https://github.com/wintercms/storm/pull/2…
tschallacka Apr 29, 2021
5a75f0a
Reverted to original
tschallacka Apr 29, 2021
0d38c6b
Renamed to to to conflict with the static variable in Eloquent\Model
tschallacka Apr 29, 2021
488952d
Removed Throwable and Exception imports, added root namespace in fron…
tschallacka Apr 29, 2021
43f521e
Added unit test for dispatcher on changed events that are accepted on…
tschallacka Apr 29, 2021
943d516
Merge branch '1.2' of https://github.com/tschallacka/storm into 1.2
tschallacka Apr 29, 2021
2e7c58c
Update tests/fixtures/events/EventTest.php
LukeTowers Apr 29, 2021
99be292
Update composer.json
LukeTowers Apr 29, 2021
3c3a437
Fixed code sniffer errors. Also learned how to run code sniffer.
Apr 30, 2021
6e7f2ff
Moved non public api methods to use throwable in the method name to r…
tschallacka May 3, 2021
652c7b8
Targetting dev-master for laravel 9
tschallacka May 3, 2021
1cda0eb
Added unit tests for priorities in event handlers
tschallacka May 6, 2021
2813f8d
Upgraded emitter to accept Events like Dispatcher does
tschallacka May 9, 2021
6da4242
Removed constants per descission https://github.com/wintercms/storm/p…
tschallacka May 11, 2021
e0c8e33
Update src/Extension/ExtendableTrait.php
LukeTowers May 12, 2021
0e88018
Code quality fix
tschallacka May 12, 2021
5397549
Code quality fix
tschallacka May 12, 2021
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
max-parallel: 6
matrix:
operatingSystem: [ubuntu-latest, windows-latest]
phpVersion: ['7.2', '7.3', '7.4', '8.0']
phpVersion: ['7.4', '8.0']
fail-fast: false
runs-on: ${{ matrix.operatingSystem }}
name: ${{ matrix.operatingSystem }} / PHP ${{ matrix.phpVersion }}
Expand Down
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ composer.lock

# Other files
.DS_Store
php_errors.log
php_errors.log

#eclipse
/.buildpath
/.project
/.settings/

#phpunit
tests/.phpunit.result.cache
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}
],
"require": {
"php": ">=7.2.9",
"php": ">=7.4",
"ext-ctype": "*",
"ext-curl": "*",
"ext-dom": "*",
Expand All @@ -39,12 +39,12 @@
"linkorb/jsmin-php": "~1.0",
"wikimedia/less.php": "~3.0",
"scssphp/scssphp": "~1.0",
"symfony/yaml": "^4.4",
"symfony/yaml": "^5.1",
LukeTowers marked this conversation as resolved.
Show resolved Hide resolved
"twig/twig": "~2.0",
"league/csv": "~9.1",
"nesbot/carbon": "^2.0",
"laravel/framework": "~6.0",
"laravel/tinker": "~2.0"
"laravel/framework": "9.x-dev",
"laravel/tinker": "dev-develop"
},
"require-dev": {
"phpunit/phpunit": "^8.5.12|^9.3.3",
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Pivot.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public function __construct(ModelBase $parent, $attributes, $table, $exists = fa
/**
* Set the keys for a save update query.
*
* @param \Illuminate\Database\Eloquent\Builder
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
protected function setKeysForSaveQuery(BuilderBase $query)
protected function setKeysForSaveQuery($query)
LukeTowers marked this conversation as resolved.
Show resolved Hide resolved
{
$query->where($this->foreignKey, $this->getAttribute($this->foreignKey));

Expand Down
23 changes: 0 additions & 23 deletions src/Database/Query/Grammars/MySqlGrammar.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,9 @@
<?php namespace Winter\Storm\Database\Query\Grammars;

use Winter\Storm\Database\QueryBuilder;
use Illuminate\Database\Query\Grammars\MySqlGrammar as BaseMysqlGrammer;
use Winter\Storm\Database\Query\Grammars\Concerns\SelectConcatenations;

class MySqlGrammar extends BaseMysqlGrammer
{
use SelectConcatenations;

/**
* Compile an "upsert" statement into SQL.
*
* @param \Winter\Storm\Database\QueryBuilder $query
* @param array $values
* @param array $uniqueBy
* @param array $update
* @return string
*/
public function compileUpsert(QueryBuilder $query, array $values, array $uniqueBy, array $update)
{
$sql = $this->compileInsert($query, $values) . ' on duplicate key update ';

$columns = collect($update)->map(function ($value, $key) {
return is_numeric($key)
? $this->wrap($value) . ' = values(' . $this->wrap($value) . ')'
: $this->wrap($key) . ' = ' . $this->parameter($value);
})->implode(', ');

return $sql . $columns;
}
}
25 changes: 0 additions & 25 deletions src/Database/Query/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,9 @@
<?php namespace Winter\Storm\Database\Query\Grammars;

use Winter\Storm\Database\QueryBuilder;
use Illuminate\Database\Query\Grammars\PostgresGrammar as BasePostgresGrammer;
use Winter\Storm\Database\Query\Grammars\Concerns\SelectConcatenations;

class PostgresGrammar extends BasePostgresGrammer
{
use SelectConcatenations;

/**
* Compile an "upsert" statement into SQL.
*
* @param \Winter\Storm\Database\QueryBuilder $query
* @param array $values
* @param array $uniqueBy
* @param array $update
* @return string
*/
public function compileUpsert(QueryBuilder $query, array $values, array $uniqueBy, array $update)
{
$sql = $this->compileInsert($query, $values);

$sql .= ' on conflict (' . $this->columnize($uniqueBy) . ') do update set ';

$columns = collect($update)->map(function ($value, $key) {
return is_numeric($key)
? $this->wrap($value) . ' = ' . $this->wrapValue('excluded') . '.' . $this->wrap($value)
: $this->wrap($key) . ' = ' . $this->parameter($value);
})->implode(', ');

return $sql . $columns;
}
}
25 changes: 0 additions & 25 deletions src/Database/Query/Grammars/SQLiteGrammar.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php namespace Winter\Storm\Database\Query\Grammars;

use Winter\Storm\Database\QueryBuilder;
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Query\Grammars\SQLiteGrammar as BaseSQLiteGrammar;
use Winter\Storm\Database\Query\Grammars\Concerns\SelectConcatenations;
Expand Down Expand Up @@ -32,28 +31,4 @@ protected function compileConcat(array $parts, string $as)

return implode(' || ', $compileParts) . ' as ' . $this->wrap($as);
}

/**
* Compile an "upsert" statement into SQL.
*
* @param \Winter\Storm\Database\QueryBuilder $query
* @param array $values
* @param array $uniqueBy
* @param array $update
* @return string
*/
public function compileUpsert(QueryBuilder $query, array $values, array $uniqueBy, array $update)
{
$sql = $this->compileInsert($query, $values);

$sql .= ' on conflict (' . $this->columnize($uniqueBy) . ') do update set ';

$columns = collect($update)->map(function ($value, $key) {
return is_numeric($key)
? $this->wrap($value) . ' = ' . $this->wrapValue('excluded') . '.' . $this->wrap($value)
: $this->wrap($key) . ' = ' . $this->parameter($value);
})->implode(', ');

return $sql . $columns;
}
}
43 changes: 0 additions & 43 deletions src/Database/Query/Grammars/SqlServerGrammar.php
Original file line number Diff line number Diff line change
@@ -1,52 +1,9 @@
<?php namespace Winter\Storm\Database\Query\Grammars;

use Winter\Storm\Database\QueryBuilder;
use Illuminate\Database\Query\Grammars\SqlServerGrammar as BaseSqlServerGrammar;
use Winter\Storm\Database\Query\Grammars\Concerns\SelectConcatenations;

class SqlServerGrammar extends BaseSqlServerGrammar
{
use SelectConcatenations;

/**
* Compile an "upsert" statement into SQL.
*
* @param \Winter\Storm\Database\QueryBuilder $query
* @param array $values
* @param array $uniqueBy
* @param array $update
* @return string
*/
public function compileUpsert(QueryBuilder $query, array $values, array $uniqueBy, array $update)
{
$columns = $this->columnize(array_keys(reset($values)));

$sql = 'merge ' . $this->wrapTable($query->from) . ' ';

$parameters = collect($values)->map(function ($record) {
return '(' . $this->parameterize($record) . ')';
})->implode(', ');

$sql .= 'using (values ' . $parameters . ') ' . $this->wrapTable('laravel_source') . ' (' . $columns . ') ';

$on = collect($uniqueBy)->map(function ($column) use ($query) {
return $this->wrap('laravel_source.' . $column) . ' = ' . $this->wrap($query->from . '.' . $column);
})->implode(' and ');

$sql .= 'on ' . $on . ' ';

if ($update) {
$update = collect($update)->map(function ($value, $key) {
return is_numeric($key)
? $this->wrap($value) . ' = ' . $this->wrap('laravel_source.' . $value)
: $this->wrap($key) . ' = ' . $this->parameter($value);
})->implode(', ');

$sql .= 'when matched then update set ' . $update . ' ';
}

$sql .= 'when not matched then insert (' . $columns . ') values (' . $columns . ')';

return $sql;
}
}
6 changes: 3 additions & 3 deletions src/Database/Traits/Encryptable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait Encryptable
/**
* @var \Illuminate\Contracts\Encryption\Encrypter Encrypter instance.
*/
protected $encrypter;
protected $encrypterInstance;

/**
* @var array List of original attribute values before they were encrypted.
Expand Down Expand Up @@ -108,7 +108,7 @@ public function getOriginalEncryptableValue($attribute)
*/
public function getEncrypter()
{
return (!is_null($this->encrypter)) ? $this->encrypter : App::make('encrypter');
return (!is_null($this->encrypterInstance)) ? $this->encrypterInstance : App::make('encrypter');
}

/**
Expand All @@ -119,6 +119,6 @@ public function getEncrypter()
*/
public function setEncrypter(\Illuminate\Contracts\Encryption\Encrypter $encrypter)
{
$this->encrypter = $encrypter;
$this->encrypterInstance = $encrypter;
LukeTowers marked this conversation as resolved.
Show resolved Hide resolved
}
}
33 changes: 28 additions & 5 deletions src/Events/Dispatcher.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php namespace Winter\Storm\Events;

use Closure;
use Opis\Closure\SerializableClosure;
use ReflectionClass;
use Winter\Storm\Support\Arr;
use Winter\Storm\Support\Str;
use Illuminate\Events\Dispatcher as BaseDispatcher;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Events\QueuedClosure;

class Dispatcher extends BaseDispatcher
{
Expand All @@ -25,13 +28,30 @@ class Dispatcher extends BaseDispatcher
/**
* Register an event listener with the dispatcher.
*
* @param string|array $events
* @param mixed $listener
* @param int $priority
* @param string|array|Closure|QueuedClosure $events
* @param mixed $listener when the third parameter is omitted and a Closure or QueuedClosure is provided
* this parameter is used as an integer this is used as priority value
* @param int $priority
* @return void
*/
public function listen($events, $listener, $priority = 0)
public function listen($events, $listener = null, $priority = 0)
LukeTowers marked this conversation as resolved.
Show resolved Hide resolved
{
if ($events instanceof Closure || $events instanceof QueuedClosure) {
if ($priority === 0 && (is_int($listener) || filter_var($listener, FILTER_VALIDATE_INT))) {
$priority = (int)$listener;
}
}
if ($events instanceof Closure) {
return $this->listen($this->firstClosureParameterType($events), $events, $priority);
} elseif ($events instanceof QueuedClosure) {
return $this->listen($this->firstClosureParameterType($events->closure), $events->resolve(), $priority);
} elseif ($listener instanceof QueuedClosure) {
$listener = $listener->resolve();
}
if ($listener instanceof Closure && !($listener instanceof SerializableClosure)) {
$listener = new SerializableClosure($listener);
}

foreach ((array) $events as $event) {
if (Str::contains($event, '*')) {
$this->setupWildcardListen($event, $listener);
Expand Down Expand Up @@ -109,6 +129,9 @@ public function dispatch($event, $payload = [], $halt = false)
}

foreach ($this->getListeners($event) as $listener) {
if ($listener instanceof SerializableClosure) {
$listener = $listener->getClosure();
}
$response = $listener($event, $payload);

// If a response is returned from the listener and event halting is enabled
Expand Down Expand Up @@ -171,7 +194,7 @@ protected function sortListeners($eventName)

// If listeners exist for the given event, we will sort them by the priority
// so that we can call them in the correct order. We will cache off these
// sorted event listeners so we do not have to re-sort on every events.
// sorted event listeners so we do not have to re-sort on every event.
if (isset($this->listeners[$eventName])) {
krsort($this->listeners[$eventName]);

Expand Down
Loading