Skip to content

Commit

Permalink
PropertyWithoutAnnotation: move to declaration after accept the quick…
Browse files Browse the repository at this point in the history
…-fix;
  • Loading branch information
rentalhost committed May 31, 2017
1 parent 10b4b9e commit 2b1b53d
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ trait NotAnySoftDeletesTrait
}

/**
* @property $someProperty
* @property mixed $someProperty
*/
class EloquentCasts_WithoutPhpdoc extends Model
{
Expand All @@ -32,7 +32,7 @@ class EloquentCasts_WithoutPhpdoc extends Model
}

/** Class
* @property $someProperty
* @property mixed $someProperty
*/
class EloquentCasts_WithPhpdoc_WithoutParam extends Model
{
Expand All @@ -42,8 +42,8 @@ class EloquentCasts_WithPhpdoc_WithoutParam extends Model
}

/**
* @property $anotherProperty
* @property $someProperty
* @property mixed $anotherProperty
* @property mixed $someProperty
*/
class EloquentCasts_WithPhpdoc_WithParam_WithoutSomePropertyParam extends Model
{
Expand All @@ -53,7 +53,7 @@ class EloquentCasts_WithPhpdoc_WithParam_WithoutSomePropertyParam extends Model
}

/**
* @property $someProperty
* @property mixed $someProperty
*/
class EloquentCasts_WithPhpdoc_WithParam_WithSomePropertyParam extends Model
{
Expand Down Expand Up @@ -98,7 +98,7 @@ class CC_EloquentCasts_CastsIsNotArray extends Model
}

/**
* @property $from_new_model_instance
* @property mixed $from_new_model_instance
*/
class EloquentCasts_WithoutCastsField extends Model
{
Expand All @@ -119,8 +119,8 @@ class CC_NoEloquentModel_WithCastsField
}

/**
* @property $created_at
* @property $updated_at
* @property mixed $created_at
* @property mixed $updated_at
*/
class EloquentDates_CreatedAndUpdatedAt extends Model
{
Expand All @@ -131,8 +131,8 @@ class EloquentDates_CreatedAndUpdatedAt extends Model
}

/**
* @property $created_at
* @property $updated_at
* @property mixed $created_at
* @property mixed $updated_at
*/
class EloquentDates_CreatedAndUpdatedAt_WithConstants extends Model
{
Expand All @@ -148,14 +148,14 @@ class EloquentDates_CreatedAndUpdatedAt_WithConstants extends Model
}

/**
* @property $created_at
* @property mixed $created_at
*/
class EloquentBaseProperties extends Model
{
}

/**
* @property $updated_at
* @property mixed $updated_at
*/
class EloquentChild_ShouldConsiderParentProperties extends EloquentBaseProperties
{
Expand All @@ -166,7 +166,7 @@ class EloquentChild_ShouldConsiderParentProperties extends EloquentBasePropertie
}

/**
* @property $deleted_at
* @property mixed $deleted_at
*/
class Eloquent_TraitSoftDeletes_DirectUsageOfSoftDeletesTrait_ShouldDeclareDeletedAtProperty extends Model
{
Expand All @@ -175,7 +175,7 @@ class Eloquent_TraitSoftDeletes_DirectUsageOfSoftDeletesTrait_ShouldDeclareDelet
}

/**
* @property $deleted_at
* @property mixed $deleted_at
*/
class Eloquent_TraitSoftDeletes_ShouldDeclareDeletedAtProperty extends Model
{
Expand All @@ -184,7 +184,7 @@ class Eloquent_TraitSoftDeletes_ShouldDeclareDeletedAtProperty extends Model
}

/**
* @property $deleted_at
* @property mixed $deleted_at
*/
class Eloquent_TraitSoftDeletes_ShouldConsiderDeclarationOnClass extends Model
{
Expand All @@ -198,33 +198,33 @@ class Eloquent_ShouldCheckIfIsTheRightSoftDeletesTrait extends Model
}

/**
* @property $created_at
* @property $updated_at
* @property mixed $created_at
* @property mixed $updated_at
*/
class EloquentTimestamps_SimulatingTheEloquentModelProperty extends Model
{
protected $timestamps = true;
}

/**
* @property $created_at
* @property $updated_at
* @property mixed $created_at
* @property mixed $updated_at
*/
class EloquentTimestamps_SimulatingTheEloquentModelProperty_Child
extends EloquentTimestamps_SimulatingTheEloquentModelProperty
{
}

/**
* @property $id
* @property mixed $id
*/
class EloquentPrimaryKey_SimulatingTheEloquentModelProperty extends Model
{
protected $primaryKey = 'id';
}

/**
* @property $id
* @property mixed $id
*/
class EloquentPrimaryKey_SimulatingTheEloquentModelProperty_Child
extends EloquentPrimaryKey_SimulatingTheEloquentModelProperty
Expand All @@ -237,15 +237,15 @@ class CC_EloquentPrimaryKey_PrimaryKeyWithoutDefaultValue extends Model
}

/**
* @property $has_one
* @property $has_many
* @property $has_many_through
* @property $morph_to
* @property $morph_one
* @property $morph_many
* @property $morph_to_many
* @property $belongs_to
* @property $belongs_to_many
* @property mixed $has_one
* @property mixed $has_many
* @property mixed $has_many_through
* @property mixed $morph_to
* @property mixed $morph_one
* @property mixed $morph_many
* @property mixed $morph_to_many
* @property mixed $belongs_to
* @property mixed $belongs_to_many
*/
class EloquentRelationship_SimulatingTheEloquentModelMethods extends Model
{
Expand Down Expand Up @@ -296,16 +296,16 @@ public function belongsToMany()
}

/**
* @property $has_one_property
* @property $has_many_property
* @property $has_many_through_property
* @property $morph_to_property
* @property $morph_one_property
* @property $morph_many_property
* @property $morph_to_many_property
* @property $belongs_to_property
* @property $belongs_to_many_property
* @property $some_property
* @property mixed $has_one_property
* @property mixed $has_many_property
* @property mixed $has_many_through_property
* @property mixed $morph_to_property
* @property mixed $morph_one_property
* @property mixed $morph_many_property
* @property mixed $morph_to_many_property
* @property mixed $belongs_to_property
* @property mixed $belongs_to_many_property
* @property mixed $some_property
*/
class EloquentRelationship_HasOne extends EloquentRelationship_SimulatingTheEloquentModelMethods
{
Expand Down Expand Up @@ -364,8 +364,8 @@ public function setSomePropertyAttribute()
}

/**
* @property $some_property
* @property $repeated_property
* @property mixed $some_property
* @property mixed $repeated_property
*/
class EloquentModel_MagicGetterAndSetter extends Model
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class EloquentCasts_WithPhpdoc_WithoutParam extends Model
}

/**
* @property $anotherProperty
* @property mixed $anotherProperty
*/
class EloquentCasts_WithPhpdoc_WithParam_WithoutSomePropertyParam extends Model
{
Expand All @@ -47,7 +47,7 @@ class EloquentCasts_WithPhpdoc_WithParam_WithoutSomePropertyParam extends Model
}

/**
* @property $someProperty
* @property mixed $someProperty
*/
class EloquentCasts_WithPhpdoc_WithParam_WithSomePropertyParam extends Model
{
Expand Down Expand Up @@ -131,7 +131,7 @@ class EloquentDates_CreatedAndUpdatedAt_WithConstants extends Model
}

/**
* @property $created_at
* @property mixed $created_at
*/
class EloquentBaseProperties extends Model
{
Expand All @@ -158,7 +158,7 @@ class Eloquent_TraitSoftDeletes_ShouldDeclareDeletedAtProperty extends Model
}

/**
* @property $deleted_at
* @property mixed $deleted_at
*/
class Eloquent_TraitSoftDeletes_ShouldConsiderDeclarationOnClass extends Model
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.ide.util.PsiNavigationSupport;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
import com.intellij.pom.Navigatable;
import com.intellij.psi.*;
import com.jetbrains.php.PhpIndex;
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment;
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocProperty;
import com.jetbrains.php.lang.documentation.phpdoc.psi.tags.PhpDocTag;
import com.jetbrains.php.lang.inspections.PhpInspection;
import com.jetbrains.php.lang.psi.elements.*;
import com.jetbrains.php.lang.psi.resolve.types.PhpType;
Expand Down Expand Up @@ -408,7 +413,22 @@ public void applyFix(
}
}

PhpDocCommentUtil.createTag(primaryClass, "@property", '$' + propertyName);
final PhpDocTag docCommentNewTag = PhpDocCommentUtil.createTag(primaryClass, "@property", "mixed $" + propertyName);
final PsiElement docCommentReference = docCommentNewTag.getParent();

final Navigatable navigator = PsiNavigationSupport.getInstance().getDescriptor(docCommentReference.getNavigationElement());
if (navigator != null) {
navigator.navigate(true);

final Editor selectedTextEditor = FileEditorManager.getInstance(project).getSelectedTextEditor();
if (selectedTextEditor != null) {
final int startOffset = docCommentNewTag.getTextOffset() + 10;
final int endOffset = startOffset + 5;

selectedTextEditor.getSelectionModel().setSelection(startOffset, endOffset);
selectedTextEditor.getCaretModel().moveToOffset(endOffset);
}
}
}
}
}

0 comments on commit 2b1b53d

Please sign in to comment.