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

[11.x][PHPDOC] Fix bad phpdoc for \Illuminate\Database\Connection::$schemaGrammar #54034

Conversation

dimitriBouteille
Copy link

@dimitriBouteille dimitriBouteille commented Dec 28, 2024

This PR fix bad phpdoc in \Illuminate\Database\Connection :

  • $schemaGrammar : This property can be null or \Illuminate\Database\Schema\Grammars\Grammar

Here is an example where the property $schemaGrammar is null :

public function getSchemaBuilder()
{
if (is_null($this->schemaGrammar)) {
$this->useDefaultSchemaGrammar();
}
return new SchemaBuilder($this);

/**
* Get the default schema grammar instance.
*
* @return \Illuminate\Database\Schema\Grammars\Grammar|null
*/
protected function getDefaultSchemaGrammar()
{
//
}

@dimitriBouteille dimitriBouteille changed the title [PHPDOC] Fix bad phpdoc for \Illuminate\Database\Connection::$schemaGrammar [11.x][PHPDOC] Fix bad phpdoc for \Illuminate\Database\Connection::$schemaGrammar Dec 28, 2024
@shaedrich
Copy link
Contributor

Doesn't

protected function getDefaultGrammar()
{
    //
}

result in void rather than null? Sure, it's type-cast to null, but having the PHPDoc say void would be more correct, wouldn't it?

@dimitriBouteille
Copy link
Author

@shaedrich Is good question. For me, getDefaultGrammar must be return null by default. The function useDefaultSchemaGrammar call getDefaultGrammar, void is invalid type ...

/**
* Set the schema grammar to the default implementation.
*
* @return void
*/
public function useDefaultSchemaGrammar()
{
$this->schemaGrammar = $this->getDefaultSchemaGrammar();
}
/**
* Get the default schema grammar instance.
*
* @return \Illuminate\Database\Schema\Grammars\Grammar|null
*/
protected function getDefaultSchemaGrammar()
{
//
}

@shaedrich
Copy link
Contributor

Since when is void invalid? Sure, it's only a return type, but that doesn't make it less valid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants