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

PHP8.2 & Laravel 10 update #374

Open
wants to merge 18 commits into
base: main
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
30 changes: 18 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@
}
],
"require": {
"php": ">=7.4",
"illuminate/container": "^8.0",
"illuminate/contracts": "^8.0",
"illuminate/database": "^8.0",
"illuminate/events": "^8.0",
"illuminate/support": "^8.0",
"illuminate/pagination": "^8.0",
"php": "^8.2",
"illuminate/container": "^10.0",
"illuminate/contracts": "^10.0",
"illuminate/database": "^10.0",
"illuminate/events": "^10.0",
"illuminate/support": "^10.0",
"illuminate/pagination": "^10.0",
"illuminate/console": "^10.0",
"nesbot/carbon": "^2.0",
"laudis/neo4j-php-client": "^2.3.3"
"laudis/neo4j-php-client": "^3.0"
},
"require-dev": {
"mockery/mockery": "~1.3.0",
"phpunit/phpunit": "^9.0",
"mockery/mockery": "~1.6.0",
"phpunit/phpunit": "^10.0",
"symfony/var-dumper": "*",
"fzaninotto/faker": "~1.4",
"composer/composer": "^2.1"
"fakerphp/faker": "^1.9.1",
"composer/composer": "^2.6"
},
"autoload": {
"psr-4": {
Expand All @@ -54,5 +55,10 @@
"Vinelab\\NeoEloquent\\NeoEloquentServiceProvider"
]
}
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
6 changes: 2 additions & 4 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -926,11 +926,9 @@ public function node($label)

return $query->from($label);
}

/**
* Get a new query builder instance.
*
* @return \Illuminate\Database\Query\Builder
*/
public function query()
{
Expand Down Expand Up @@ -1071,7 +1069,7 @@ public function reconnect()
/**
* Reconnect to the database if a PDO connection is missing.
*/
protected function reconnectIfMissingConnection()
public function reconnectIfMissingConnection()
{
if (is_null($this->getClient())) {
$this->reconnect();
Expand Down
21 changes: 9 additions & 12 deletions src/ConnectionAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
namespace Vinelab\NeoEloquent;

use Closure;
use Exception;
use Illuminate\Support\Facades\App;
use Throwable;
use Vinelab\NeoEloquent\Exceptions\QueryException;
use Vinelab\NeoEloquent\ConnectionInterface;

use Illuminate\Contracts\Events\Dispatcher as IlluminateDispatcher;
use Illuminate\Database\Query\Grammars\Grammar;
use Illuminate\Database\Query\Processors\Processor;
Expand Down Expand Up @@ -369,7 +367,7 @@ public function reconnect()
*
* @return void
*/
protected function reconnectIfMissingConnection()
public function reconnectIfMissingConnection()
{
$this->neoeloquent->reconnectIfMissingConnection();
}
Expand Down Expand Up @@ -535,15 +533,14 @@ public function getEventDispatcher()
return $this->neoeloquent->getEventDispatcher();
}

/**
* Set the event dispatcher instance on the connection.
*
* @param \Illuminate\Contracts\Events\Dispatcher
* @return void
*/
public function setEventDispatcher(IlluminateDispatcher $events)
/**
* @param IlluminateDispatcher $events
*
* @return void
*/
public function setEventDispatcher(IlluminateDispatcher $events)
{
$this->neoeloquent->setEventDispatcher(\App::make(Dispatcher::class));
$this->neoeloquent->setEventDispatcher(App::make(Dispatcher::class));
}

/**
Expand Down
60 changes: 19 additions & 41 deletions src/Console/Migrations/MigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,61 +20,39 @@ class MigrateCommand extends BaseCommand
*/
protected $description = 'Run the database migrations';

/**
* The migrator instance.
*
* @var \Vinelab\NeoEloquent\Migrations\Migrator
*/
protected $migrator;

/**
* The path to the packages directory (vendor).
*/
protected $packagePath;

/**
* @param \Vinelab\NeoEloquent\Migrations\Migrator $migrator
* @param string $packagePath
*/
public function __construct(Migrator $migrator, $packagePath)
public function __construct(protected Migrator $migrator, protected string $packagePath)
{
parent::__construct();

$this->migrator = $migrator;
$this->packagePath = $packagePath;
}

/**
* {@inheritDoc}
*/
public function fire()
public function handle()
{
if (!$this->confirmToProceed()) {
if(!$this->confirmToProceed()) {
return;
}

// The pretend option can be used for "simulating" the migration and grabbing
// the SQL queries that would fire if the migration were to be run against
// a database for real, which is helpful for double checking migrations.
$pretend = $this->input->getOption('pretend');
$pretend = $this->input->getOption(name: 'pretend');

$path = $this->getMigrationPath();

$this->migrator->setConnection($this->input->getOption('database'));
$this->migrator->run($path, ['pretend' => $pretend]);
$this->migrator->setConnection(name: $this->input->getOption(name: 'database'));
$this->migrator->run(paths: $path, options: ['pretend' => $pretend]);

// Once the migrator has run we will grab the note output and send it out to
// the console screen, since the migrator itself functions without having
// any instances of the OutputInterface contract passed into the class.
foreach ($this->migrator->getNotes() as $note) {
$this->output->writeln($note);
foreach($this->migrator->getNotes() as $note) {
$this->output->writeln(messages: $note);
}

// Finally, if the "seed" option has been given, we will re-run the database
// seed task to re-populate the database, which is convenient when adding
// a migration and a seed at the same time, as it is only this command.
if ($this->input->getOption('seed')) {
$this->call('db:seed', ['--force' => true]);
if($this->input->getOption(name: 'seed')) {
$this->call(command: 'db:seed', arguments: ['--force' => true]);
}
}

Expand All @@ -83,20 +61,20 @@ public function fire()
*/
protected function getOptions()
{
return array(
array('bench', null, InputOption::VALUE_OPTIONAL, 'The name of the workbench to migrate.', null),
return [
['bench', null, InputOption::VALUE_OPTIONAL, 'The name of the workbench to migrate.', null],

array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'),
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],

array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'),
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],

array('path', null, InputOption::VALUE_OPTIONAL, 'The path to migration files.', null),
['path', null, InputOption::VALUE_OPTIONAL, 'The path to migration files.', null],

array('package', null, InputOption::VALUE_OPTIONAL, 'The package to migrate.', null),
['package', null, InputOption::VALUE_OPTIONAL, 'The package to migrate.', null],

array('pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'),
['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'],

array('seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'),
);
['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'],
];
}
}
80 changes: 24 additions & 56 deletions src/Console/Migrations/MigrateMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Vinelab\NeoEloquent\Console\Migrations;

use Exception;
use Illuminate\Support\Composer;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -19,105 +20,72 @@ class MigrateMakeCommand extends BaseCommand
*/
protected $description = 'Create a new migration file';

/**
* @var \Vinelab\NeoEloquent\Migrations\MigrationCreator
*/
protected $creator;

/**
* The path to the packages directory (vendor).
*
* @var string
*/
protected $packagePath;

/**
* @var \Illuminate\Foundation\Composer
*/
protected $composer;

/**
* @param \Vinelab\NeoEloquent\Migrations\MigrationCreator $creator
* @param string $packagePath
*/
public function __construct(MigrationCreator $creator, Composer $composer, $packagePath)
public function __construct(protected MigrationCreator $creator, protected Composer $composer, protected string $packagePath)
{
parent::__construct();

$this->creator = $creator;
$this->packagePath = $packagePath;
$this->composer = $composer;
}

/**
* {@inheritDoc}
*/
public function fire()
public function handle(): void
{
// It's possible for the developer to specify the tables to modify in this
// schema operation. The developer may also specify if this label needs
// to be freshly created so we can create the appropriate migrations.
$name = $this->input->getArgument('name');
$name = $this->input->getArgument(name: 'name');

$label = $this->input->getOption('label');
$label = $this->input->getOption(name: 'label');

$modify = $this->input->getOption('create');
$modify = $this->input->getOption(name: 'create');

if (!$label && is_string($modify)) {
if(!$label && \is_string(value: $modify)) {
$label = $modify;
}

// Now we are ready to write the migration out to disk. Once we've written
// the migration out, we will dump-autoload for the entire framework to
// make sure that the migrations are registered by the class loaders.
$this->writeMigration($name, $label);
$this->writeMigration(name: $name, label: $label);

$this->composer->dumpAutoloads();
}

/**
* Write the migration file to disk.
*
* @param string $name
* @param string $label
* @param bool $create
*
* @return string
* @throws Exception
*/
protected function writeMigration($name, $label)
protected function writeMigration(string $name, string $label = null): void
{
$path = $this->getMigrationPath();

$file = pathinfo($this->creator->create($name, $path, $label), PATHINFO_FILENAME);
$file = pathinfo(path: $this->creator->create(name: $name, path: $path, table: $label), flags: PATHINFO_FILENAME);

$this->line("<info>Created Migration:</info> $file");
$this->line(string: "<info>Created Migration:</info> $file");
}

/**
* {@inheritDoc}
*/
protected function getArguments()
protected function getArguments(): array
{
return array(
array('name', InputArgument::REQUIRED, 'The name of the migration'),
);
return [
['name', InputArgument::REQUIRED, 'The name of the migration'],
];
}

/**
* {@inheritDoc}
*/
protected function getOptions()
protected function getOptions(): array
{
return array(
array('bench', null, InputOption::VALUE_OPTIONAL, 'The workbench the migration belongs to.', null),
return [
['bench', null, InputOption::VALUE_OPTIONAL, 'The workbench the migration belongs to.', null],

array('create', null, InputOption::VALUE_OPTIONAL, 'The label schema to be created.'),
['create', null, InputOption::VALUE_OPTIONAL, 'The label schema to be created.'],

array('package', null, InputOption::VALUE_OPTIONAL, 'The package the migration belongs to.', null),
['package', null, InputOption::VALUE_OPTIONAL, 'The package the migration belongs to.', null],

array('path', null, InputOption::VALUE_OPTIONAL, 'Where to store the migration.', null),
['path', null, InputOption::VALUE_OPTIONAL, 'Where to store the migration.', null],

array('label', null, InputOption::VALUE_OPTIONAL, 'The label to migrate.'),
);
['label', null, InputOption::VALUE_OPTIONAL, 'The label to migrate.'],
];
}
}
2 changes: 1 addition & 1 deletion src/Eloquent/Edges/Delegate.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public function asNode(Model $model): ?Node
unset($properties['id']);
}

return new Node($id, new CypherList([$label]), new CypherMap($properties));
return new Node($id, new CypherList([$label]), new CypherMap($properties), null);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ public function newEloquentBuilder($query)
* @override
* Get a new query builder instance for the connection.
*
* @return Vinelab\NeoEloquent\Query\Builder
* @return QueryBuilder
*/
protected function newBaseQueryBuilder()
{
Expand Down
Loading