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

Remove format and broken generateJsonHelper #1053

Merged
merged 1 commit into from
Dec 4, 2020
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ All notable changes to this project will be documented in this file.
- Allow model_locations to have glob patterns [\#1059 / saackearl](https://github.com/barryvdh/laravel-ide-helper/pull/1059)
- Error when generating helper for macroable classes which are not facades and contain a "fake" method [\#1066 / domkrm] (https://github.com/barryvdh/laravel-ide-helper/pull/1066)

### Removed
- Removed format and broken generateJsonHelper [\#1053 / mfn](https://github.com/barryvdh/laravel-ide-helper/pull/1053)

2020-09-07, 2.8.1
-----------------
### Added
Expand Down
5 changes: 2 additions & 3 deletions config/ide-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
| Filename & Format
|--------------------------------------------------------------------------
|
| The default filename (without extension) and the format (php or json)
| The default filename
|
*/

'filename' => '_ide_helper',
'format' => 'php',
'filename' => '_ide_helper.php',

/*
|--------------------------------------------------------------------------
Expand Down
14 changes: 5 additions & 9 deletions src/Console/GeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,13 @@ public function handle()
}

$filename = $this->argument('filename');
$format = $this->option('format');

// Strip the php extension
if (substr($filename, -4, 4) === '.php') {
$filename = substr($filename, 0, -4);
// Add the php extension if missing
// This is a backwards-compatible shim and can be removed in the future
if (substr($filename, -4, 4) !== '.php') {
$filename .= '.php';
}

$filename .= '.' . $format;

if ($this->option('memory')) {
$this->useMemoryDriver();
}
Expand All @@ -115,7 +113,7 @@ public function handle()
}

$generator = new Generator($this->config, $this->view, $this->getOutput(), $helpers);
$content = $generator->generate($format);
$content = $generator->generate();
$written = $this->files->put($filename, $content);

if ($written !== false) {
Expand Down Expand Up @@ -165,11 +163,9 @@ protected function getArguments()
*/
protected function getOptions()
{
$format = $this->config->get('ide-helper.format');
$writeMixins = $this->config->get('ide-helper.write_eloquent_model_mixins');

return [
['format', 'F', InputOption::VALUE_OPTIONAL, 'The format for the IDE Helper', $format],
['write_mixins', 'W', InputOption::VALUE_OPTIONAL, 'Write mixins to Laravel Model?', $writeMixins],
['helpers', 'H', InputOption::VALUE_NONE, 'Include the helper files'],
['memory', 'M', InputOption::VALUE_NONE, 'Use sqlite memory driver'],
Expand Down
41 changes: 1 addition & 40 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,9 @@ public function __construct(
/**
* Generate the helper file contents;
*
* @param string $format The format to generate the helper in (php/json)
* @return string;
*/
public function generate($format = 'php')
{
// Check if the generator for this format exists
$method = 'generate' . ucfirst($format) . 'Helper';
if (method_exists($this, $method)) {
return $this->$method();
}

return $this->generatePhpHelper();
}

public function generatePhpHelper()
public function generate()
{
$app = app();
return $this->view->make('helper')
Expand All @@ -94,33 +82,6 @@ public function generatePhpHelper()
->render();
}

public function generateJsonHelper()
{
$classes = [];
foreach ($this->getValidAliases() as $aliases) {
foreach ($aliases as $alias) {
$functions = [];
foreach ($alias->getMethods() as $method) {
$functions[$method->getName()] = '(' . $method->getParamsWithDefault() . ')';
}
$classes[$alias->getAlias()] = [
'functions' => $functions,
];
}
}

$flags = JSON_FORCE_OBJECT;
if (defined('JSON_PRETTY_PRINT')) {
$flags |= JSON_PRETTY_PRINT;
}

return json_encode([
'php' => [
'classes' => $classes,
],
], $flags);
}

protected function detectDrivers()
{
$defaultUserModel = config('auth.providers.users.model', config('auth.model', 'App\User'));
Expand Down