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

Use @var instead of @param #3002

Merged
merged 4 commits into from
Feb 6, 2018
Merged

Use @var instead of @param #3002

merged 4 commits into from
Feb 6, 2018

Conversation

carusogabriel
Copy link
Contributor

As requested by @morozov in #2996

@morozov
Copy link
Member

morozov commented Jan 29, 2018

There are ~10 issues like this in the code base. Could you please fix them all?

↪ phpcs | grep 'does not have @var annotation' | wc -l
10

@@ -4,9 +4,24 @@

class ConnectionMock extends \Doctrine\DBAL\Connection
{
/**
* @var
*/
private $_fetchOneResult;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@morozov What should we use here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely mixed, try checking for the setter calls to discover its type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess is mixed. I can't find a single reference, even in Doctrine\DBAL\Connection 😞

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ocramius We are discussing the missing mixed here 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove it together with setFetchOneResult() and it doesn't break tests, I'd consider it the correct approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is up to you guys: mixed, or remove fetchColumn and setFetchOneResult methods?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carusogabriel please remove the unused methods if it doesn't affect existing tests.

@@ -9,7 +9,14 @@
*/
class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
{
/**
* @var Type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong. This is int[][]|string[][]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost all the array notations are reporting an error. I'm working on that 🚧

@@ -4,9 +4,24 @@

class ConnectionMock extends \Doctrine\DBAL\Connection
{
/**
* @var
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment to track the missing mixed

private $expectedResult = array(array('test_int' => 100, 'test_string' => 'foo'), array('test_int' => 200, 'test_string' => 'bar'), array('test_int' => 300, 'test_string' => 'baz'));

/**
* @var \Doctrine\DBAL\Logging\DebugStack
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move fully qualified names to the use section and use aliases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we add this to our CS as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we do have the check for class names in the code but it doesn't work for comments. Inspecting:

<?php

$conn = new \Doctrine\DBAL\Connection();

will produce:

------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------
 3 | ERROR | [x] Class \Doctrine\DBAL\Connection should not be referenced via a fully qualified
   |       |     name, but via a use statement.
------------------------------------------------------------------------------------------------

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@morozov Can you create brief repro code & report to Slevomat repo? It may've simply been overlooked since Slevomat guys afaik prefer FQCN in params/typehints. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$_platform,
$_type;
/**
* @var MockPlatform
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MockPlatform doesn't define any new API which is not defined in AbstractPlatform. Could we declare this property as AbstractPlatform and consider the mock an implementation detail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@morozov What do you suggest?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carusogabriel @morozov is suggesting to simply document this as AbstractPlatform

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ocramius Done!

@@ -4,9 +4,19 @@

class ConnectionMock extends \Doctrine\DBAL\Connection
{
private $_fetchOneResult;
/**
* @var DatabasePlatformMock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike the previous platform mock, this type cannot be replaced with the abstract class (no action required).

private $_platformMock;

/**
* @var SchemaManagerMock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be replaced with AbstractSchemaManager.

@carusogabriel
Copy link
Contributor Author

carusogabriel commented Feb 5, 2018

Sorry, I must have missed some notifications about this PR and leave without changes.

@morozov I'll update it with your requested changes. About the @kukulich's new option, should we use this PR to test?

@morozov
Copy link
Member

morozov commented Feb 5, 2018

@carusogabriel let's fix whatever is identified now. We can fix newly identified issues consistently in another patch.

@Ocramius Ocramius added this to the 2.7.0 milestone Feb 6, 2018
@Ocramius
Copy link
Member

Ocramius commented Feb 6, 2018

🚢

@Ocramius Ocramius merged commit ec85e54 into doctrine:master Feb 6, 2018
@carusogabriel carusogabriel deleted the missing-annotations branch February 6, 2018 11:30
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants