Skip to content

Commit

Permalink
stan fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobg committed Mar 12, 2021
1 parent 0b03bbe commit bd8d32c
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Modelarium/Frontend/FrontendVueGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getOptions(): Options
return $this->generator->getOptions();
}

public function getStubDir()
public function getStubDir(): string
{
return $this->generator->getStubDir() . '/Vue/';
}
Expand Down Expand Up @@ -332,7 +332,7 @@ public function vueTableItem(FrameworkVue $vue): void
if ($f->getDatatype()->getBasetype() === 'relationship') {
$prop['default'] = '() => null';
} else {
$prop['default'] = $f->getDatatype()->getDefault;
$prop['default'] = $f->getDatatype()->getDefault();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,12 @@ public function handle()
$name = $this->argument('name');

// setup stuff
// @phpstan-ignore-next-line
$this->frameworks = $this->option('framework') ?: $this->modelariumOptions->getOption('frontend', 'framework');
if (empty($this->frameworks)) {
$this->error('If you are generating frontend you need to specify frameworks. Example: `--framework=HTML --framework=Bootstrap --framework=Vue`');
return;
}
if (!is_array($this->frameworks)) {
// @phpstan-ignore-next-line
$this->frameworks = [$this->frameworks];
}

Expand Down Expand Up @@ -115,7 +113,7 @@ protected function loadParser(): void
$files = [
__DIR__ . '/../../../Types/Graphql/scalars.graphql'
];
if ($this->option('lighthouse') || $this->modelariumOptions->getSection('modelarium', 'lighthouse')) {
if ($this->option('lighthouse') || $this->modelariumOptions->getOption('modelarium', 'lighthouse')) {
$files[] = __DIR__ . '/../../Graphql/definitionsLighthouse.graphql';
}

Expand Down
3 changes: 3 additions & 0 deletions Modelarium/Laravel/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
use Nuwave\Lighthouse\Events\RegisterDirectiveNamespaces;

use function Safe\scandir;

class ServiceProvider extends LaravelServiceProvider
{
/**
Expand Down Expand Up @@ -44,6 +46,7 @@ public function boot(): void
* Publishing
*/
$this->publishes([
//
__DIR__ . '/../Config/modelarium.php' => config_path('modelarium.php'),
], 'config');

Expand Down
9 changes: 5 additions & 4 deletions Modelarium/Laravel/Targets/MigrationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use function Safe\array_combine;
use function Safe\rsort;
use function Safe\date;
use function Safe\preg_match;

function getStringBetween(string $string, string $start, string $end): string
{
Expand Down Expand Up @@ -525,12 +526,13 @@ protected function checkMigrationCodeChange(string $newcode): bool
return true;
}
$tokens = token_get_all($this->lastMigrationCode);
for ($i=0,$z=count($tokens); $i<$z; $i++) {
if (is_array($tokens[$i]) && $tokens[$i] === T_FUNCTION
for ($i=0, $z=count($tokens); $i < $z; $i++) {
if (is_array($tokens[$i]) && $tokens[$i][0] === T_FUNCTION
&& is_array($tokens[$i+1]) && $tokens[$i+1][0] == T_WHITESPACE
&& is_array($tokens[$i+2]) && $tokens[$i+2][1] == 'up'
) {
$accumulator = [];
$braceDepth = 0;
// collect tokens from function head through opening brace
while ($tokens[$i] != '{' && ($i < $z)) {
$accumulator[] = is_array($tokens[$i]) ? $tokens[$i][1] : $tokens[$i];
Expand All @@ -556,8 +558,7 @@ protected function checkMigrationCodeChange(string $newcode): bool
}
}
}
$functionSrc = implode(null, $accumulator);
var_dump($functionSrc, $newcode);
$functionSrc = implode("", $accumulator);
if ($functionSrc == $newcode) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions Modelarium/Laravel/Targets/ModelGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ protected function processRelationship(
if (!$relationshipDatatype) {
// if target is a model...
$targetType = $this->parser->getSchema()->getType($typeName);
/** @phpstan-ignore-next-line */
$directives = $targetType->astNode->directives;
$skip = false;
foreach ($directives as $directive) {
Expand Down
4 changes: 2 additions & 2 deletions Modelarium/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function loadOptions(): array
return $config;
}

protected static function mergeArrays(array $base, array $merge)
protected static function mergeArrays(array $base, array $merge): array
{
$newarray = [];
foreach ($base as $key => $val) {
Expand All @@ -112,7 +112,7 @@ protected static function mergeArrays(array $base, array $merge)
return $newarray;
}

protected static function isAssoc(array $arr)
protected static function isAssoc(array $arr): bool
{
if (array() === $arr) {
return false;
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ parameters:
level: 7
ignoreErrors:
- "#Function base_path not found.#"
- "#Function config_path not found.#"
paths:
- Modelarium/
- tests/
Expand Down

0 comments on commit bd8d32c

Please sign in to comment.