Skip to content
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
12 changes: 12 additions & 0 deletions config/ide-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@

'include_fluent' => false,

/*
|--------------------------------------------------------------------------
| Request stub generation
|--------------------------------------------------------------------------
|
| Set to true to generate complete Request class stubs including all methods.
| This helps prevent conflicts with PHP Intelephense extension.
|
*/

'include_complete_request_stubs' => true,

/*
|--------------------------------------------------------------------------
| Factory builders
Expand Down
4 changes: 4 additions & 0 deletions src/Console/ModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,10 @@ public function getParameters($method)
//$default = $default;
} elseif ($default instanceof \UnitEnum) {
$default = '\\' . get_class($default) . '::' . $default->name;
} elseif (is_object($default)) {
// Handle object initializers
$reflection = new \ReflectionObject($default);
$default = 'new \\' . $reflection->getName() . '()';
} else {
$default = "'" . trim($default) . "'";
}
Expand Down
66 changes: 66 additions & 0 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ public function __construct(
public function generate()
{
$app = app();
$aliases = $this->getAliases();

// Handle Request class specially if complete stubs are enabled
if ($this->config->get('ide-helper.include_complete_request_stubs', true)) {
foreach ($aliases as $alias) {
if ($alias->getExtends() === 'Illuminate\Http\Request') {
$this->addCompleteRequestMethods($alias);
}
}
}

return $this->view->make('ide-helper::helper')
->with('namespaces_by_extends_ns', $this->getAliasesByExtendsNamespace())
->with('namespaces_by_alias_ns', $this->getAliasesByAliasNamespace())
Expand Down Expand Up @@ -404,4 +415,59 @@ protected function getMacroableClasses(Collection $aliases)
});
});
}

/**
* Add complete Request class methods to the alias
*
* @param Alias $alias
* @return void
*/
protected function addCompleteRequestMethods(Alias $alias)
{
$methods = [
'input' => 'mixed',
'route' => 'mixed',
'file' => 'mixed',
'hasFile' => 'bool',
'all' => 'array',
'only' => 'array',
'except' => 'array',
'query' => 'mixed',
'cookie' => 'mixed',
'header' => 'mixed',
'server' => 'mixed',
'session' => 'mixed',
'old' => 'mixed',
'flash' => 'void',
'flashOnly' => 'void',
'flashExcept' => 'void',
'flush' => 'void',
'merge' => 'void',
'replace' => 'void',
'json' => 'mixed',
'isJson' => 'bool',
'wantsJson' => 'bool',
'is' => 'bool',
'routeIs' => 'bool',
'fullUrl' => 'string',
'url' => 'string',
'path' => 'string',
'decodedPath' => 'string',
'root' => 'string',
'method' => 'string',
'isMethod' => 'bool',
'bearerToken' => 'string',
'ip' => 'string',
'ips' => 'array',
'userAgent' => 'string',
'secure' => 'bool',
'ajax' => 'bool',
'pjax' => 'bool',
'prefetch' => 'bool',
];

foreach ($methods as $method => $returnType) {
$alias->addMethod($method, [], $returnType);
}
}
}