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

Apply Pint Formatting #85

Closed
wants to merge 3 commits into from
Closed
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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"laravel/sanctum": "^4.0"
},
"require-dev": {
"laravel/pint": "^1.14",
"laravel/sail": "^1.26",
"orchestra/testbench": "^9.0",
"phpunit/phpunit": "^10.5"
Expand Down
2 changes: 1 addition & 1 deletion config/protector.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@
| The default is 120 seconds.
|
*/
'httpTimeout' => env('PROTECTOR_HTTP_TIMEOUT', 120)
'httpTimeout' => env('PROTECTOR_HTTP_TIMEOUT', 120),
];
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ services:
- '.:/var/www/html'
networks:
- internal
- shared
depends_on:
- mysql_testing
mysql_testing:
Expand All @@ -40,3 +41,5 @@ services:
networks:
internal:
internal: true
shared:
external: true
37 changes: 37 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"preset": "laravel",
"rules": {
"blank_line_before_statement": {
"statements": [
"break",
"continue",
"do",
"exit",
"for",
"foreach",
"if",
"phpdoc",
"return",
"switch",
"throw",
"try",
"while",
"yield",
"yield_from"
]
},
"class_attributes_separation": {
"elements": {
"const": "none",
"property": "none"
}
},
"concat_space": {
"spacing": "one"
},
"no_superfluous_phpdoc_tags": true,
"not_operator_with_successor_space": false,
"phpdoc_separation": true,
"phpdoc_trim_consecutive_blank_line_separation": true
}
}
6 changes: 2 additions & 4 deletions src/Classes/AbstractMySqlSchemaStateProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
namespace Cybex\Protector\Classes;

use Cybex\Protector\Protector;
use Exception;
use Illuminate\Database\Connection;
use Illuminate\Database\Schema\MySqlSchemaState;
use Illuminate\Database\Schema\SchemaState;
use Symfony\Component\Process\Process;

/**
Expand All @@ -19,15 +17,15 @@ public function __construct(protected MySqlSchemaState $schemaState, protected P
}

/**
* @inheritDoc
* {@inheritDoc}
*/
public function dump(Connection $connection, $path)
{
$this->schemaState->dump(...func_get_args());
}

/**
* @inheritDoc
* {@inheritDoc}
*/
public function load($path)
{
Expand Down
20 changes: 10 additions & 10 deletions src/Classes/MySqlSchemaStateProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class MySqlSchemaStateProxy extends AbstractMySqlSchemaStateProxy
{
/**
* @inheritDoc
* {@inheritDoc}
*/
public function dump(Connection $connection, $path)
{
Expand All @@ -23,7 +23,7 @@ public function dump(Connection $connection, $path)
$this->schemaState->output,
array_merge(
$this->baseVariables($this->schemaState->connection->getConfig()),
['LARAVEL_LOAD_PATH' => $path,]
['LARAVEL_LOAD_PATH' => $path]
)
);

Expand All @@ -33,7 +33,7 @@ public function dump(Connection $connection, $path)
}

/**
* @inheritDoc
* {@inheritDoc}
*/
public function load($path)
{
Expand All @@ -45,14 +45,14 @@ public function load($path)
*/
protected function getCommandString(): string
{
$command = 'mysqldump '.$this->schemaState->connectionString().' ';
$command = 'mysqldump ' . $this->schemaState->connectionString() . ' ';

$conditionalParameters = [
'--set-gtid-purged=OFF' => !$this->schemaState->connection->isMaria(),
'--no-create-db' => !$this->protector->shouldCreateDb(),
'--skip-comments' => !$this->protector->shouldDumpComments(),
'--skip-set-charset' => !$this->protector->shouldDumpCharsets(),
'--no-data' => !$this->protector->shouldDumpData(),
'--no-create-db' => !$this->protector->shouldCreateDb(),
'--skip-comments' => !$this->protector->shouldDumpComments(),
'--skip-set-charset' => !$this->protector->shouldDumpCharsets(),
'--no-data' => !$this->protector->shouldDumpData(),
];

$parameters = [
Expand All @@ -61,11 +61,11 @@ protected function getCommandString(): string
'--tz-utc',
'--column-statistics=0',
'--result-file="${:LARAVEL_LOAD_PATH}"',
'--max-allowed-packet='.$this->protector->getMaxPacketLength(),
'--max-allowed-packet=' . $this->protector->getMaxPacketLength(),
...array_keys(array_filter($conditionalParameters)),
'"${:LARAVEL_LOAD_DATABASE}"',
];

return $command.implode(' ', $parameters);
return $command . implode(' ', $parameters);
}
}
1 change: 0 additions & 1 deletion src/Commands/CreateKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

/**
* Class CreateKeys
* @package Cybex\Protector\Commands;
*/
class CreateKeys extends Command
{
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CreateToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

/**
* Class CreateToken
* @package Cybex\Protector\Commands;
*/
class CreateToken extends Command
{
Expand Down Expand Up @@ -42,6 +41,7 @@ public function handle()
$this->error(
'The user doesn\'t have a protector public key and none was specified. Please provide a public key for the user.'
);

return null;
}

Expand Down
3 changes: 0 additions & 3 deletions src/Commands/ExportDump.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/**
* Class ExportDump
* @package Cybex\Protector\Commands;
*/
class ExportDump extends Command
{
Expand All @@ -33,8 +32,6 @@ class ExportDump extends Command

/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
Expand Down
24 changes: 9 additions & 15 deletions src/Commands/ImportDump.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

/**
* Class ImportDump
*
* @package Cybex\Protector\Commands
*/
class ImportDump extends Command
{
Expand Down Expand Up @@ -47,12 +45,12 @@ class ImportDump extends Command

protected const DOWNLOAD_REMOTE_DUMP = 'Download remote dump';
protected const IMPORT_EXISTING_LOCAL_DUMP = 'Import existing local dump';

protected ?Protector $protector = null;

/**
* Execute the console command.
*
* @return int
* @throws InvalidEnvironmentException
*/
public function handle(): int
Expand Down Expand Up @@ -119,8 +117,6 @@ public function handle(): int

/**
* Reads the remote dump file and deletes all old dumps if the flush option is set.
*
* @return string|null
*/
protected function getRemoteDump(): ?string
{
Expand Down Expand Up @@ -220,9 +216,9 @@ public function getMetaDataForFiles(array $directoryFiles): Collection
}

if (($metaData['meta']['connection'] ?? false) && Arr::exists(
config('database.connections'),
$metaData['meta']['connection']
)) {
config('database.connections'),
$metaData['meta']['connection']
)) {
$fileInformation = [
'path' => $directoryFile,
'file' => basename($directoryFile),
Expand Down Expand Up @@ -269,11 +265,11 @@ public function getMetaDataForFiles(array $directoryFiles): Collection
protected function importDump(string $importFilePath, ?bool $optionForce): void
{
if ($optionForce || $this->confirm(
sprintf(
'Are you sure that you want to import the dump into the database: %s?',
$this->protector->getDatabaseName()
)
)) {
sprintf(
'Are you sure that you want to import the dump into the database: %s?',
$this->protector->getDatabaseName()
)
)) {
try {
$this->protector->importDump($importFilePath, Arr::except($this->options(), ['migrate']));

Expand Down Expand Up @@ -322,8 +318,6 @@ public function getConnectionFiles(?string $connectionName = null): Collection

/**
* Asks if an existing dump or a remote dump should be imported.
*
* @return bool
*/
protected function userWantsRemoteDump(): bool
{
Expand Down
4 changes: 1 addition & 3 deletions src/Exceptions/EmptyBaseDirectoryException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
* Class FailedShellCommandException
*
* Thrown if a shell command couldn't be executed properly.
*
* @package Cybex\Protector\Exceptions
*/
class EmptyBaseDirectoryException extends Exception
{
public function __construct($message = '', $code = 0, Throwable $previous = null)
public function __construct($message = '', $code = 0, ?Throwable $previous = null)
{
parent::__construct($message ?: 'There are no dumps in the dump folder', $code, $previous);
}
Expand Down
3 changes: 0 additions & 3 deletions src/Exceptions/FailedCreatingDestinationPathException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
* Class FailedCreatingDestinationPathException
*
* Thrown if the destination path could not be created.
*
* @package Cybex\Protector\Exceptions
*/
class FailedCreatingDestinationPathException extends Exception
{

}
2 changes: 0 additions & 2 deletions src/Exceptions/FailedDumpGenerationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* Class FailedDumpGenerationException
*
* Thrown if the generation of the MySQL dump has failed.
*
* @package Cybex\Protector\Exceptions
*/
class FailedDumpGenerationException extends Exception
{
Expand Down
4 changes: 1 addition & 3 deletions src/Exceptions/FailedMysqlCommandException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
* Class FailedShellCommandException
*
* Thrown if a shell command couldn't be executed properly.
*
* @package Cybex\Protector\Exceptions
*/
class FailedMysqlCommandException extends Exception
{
public function __construct($message = '', $code = 0, Throwable $previous = null)
public function __construct($message = '', $code = 0, ?Throwable $previous = null)
{
parent::__construct($message ?: 'Shell call to mysql client failed.', $code, $previous);
}
Expand Down
3 changes: 0 additions & 3 deletions src/Exceptions/FailedRemoteDatabaseFetchingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
* Class FailedRemoteDatabaseFetchingException
*
* Thrown if the remote database could not be fetched successfully.
*
* @package Cybex\Protector\Exceptions
*/
class FailedRemoteDatabaseFetchingException extends Exception
{

}
4 changes: 1 addition & 3 deletions src/Exceptions/FileNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
* Class FileNotFoundException
*
* Thrown if a file could not be found.
*
* @package Cybex\Protector\Exceptions
*/
class FileNotFoundException extends Exception
{
public function __construct($path, $code = 0, Throwable $previous = null)
public function __construct($path, $code = 0, ?Throwable $previous = null)
{
parent::__construct(sprintf('The file "%s" was not found.', $path), $code, $previous);
}
Expand Down
2 changes: 0 additions & 2 deletions src/Exceptions/InvalidConfigurationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* Class InvalidEnvironmentException
*
* Thrown if the configuration is invalid or missing.
*
* @package Cybex\Protector\Exceptions
*/
class InvalidConfigurationException extends Exception
{
Expand Down
2 changes: 0 additions & 2 deletions src/Exceptions/InvalidConnectionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* Class InvalidConnectionException
*
* Thrown if the connection is not configured properly.
*
* @package Cybex\Protector\Exceptions
*/
class InvalidConnectionException extends Exception
{
Expand Down
2 changes: 0 additions & 2 deletions src/Exceptions/InvalidEnvironmentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* Class InvalidEnvironmentException
*
* Thrown if the environment is set to Production and Production environment was not allowed explicitly.
*
* @package Cybex\Protector\Exceptions
*/
class InvalidEnvironmentException extends Exception
{
Expand Down
4 changes: 1 addition & 3 deletions src/Exceptions/ShellAccessDeniedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
* Class ShellAccessDeniedException
*
* Thrown when the shell access is denied.
*
* @package Cybex\Protector\Exceptions
*/
class ShellAccessDeniedException extends Exception
{
public function __construct($message = '', $code = 0, Throwable $previous = null)
public function __construct($message = '', $code = 0, ?Throwable $previous = null)
{
parent::__construct(
$message ?: 'Shell commands are disabled on your server, exec() must be enabled.',
Expand Down
2 changes: 0 additions & 2 deletions src/Exceptions/UnsupportedDatabaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* Class UnsupportedDatabaseException
*
* Thrown if Protector is run in an unsupported database environment.
*
* @package Cybex\Protector\Exceptions
*/
class UnsupportedDatabaseException extends Exception
{
Expand Down
Loading
Loading