forked from ariddlestone/phpstan-cakephp2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Teach see a difference between Component and Model especially when bo…
…th have methods with the same name
- Loading branch information
Showing
10 changed files
with
149 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
class BaseController extends Controller | ||
{ | ||
/** | ||
* @var array<array-key, string> | ||
*/ | ||
public $components = ['Basic']; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
<?php | ||
|
||
class BasicController extends Controller {} | ||
class BasicController extends Controller | ||
{ | ||
/** | ||
* @var array<array-key, string> | ||
*/ | ||
public $components = ['Basic']; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
<?php | ||
|
||
class BasicComponent extends Component {} | ||
class BasicComponent extends Component | ||
{ | ||
/** | ||
* @var array<array-key, string> | ||
*/ | ||
public $components = ['Second']; | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/Feature/classes/Controller/Component/SameAsModelComponent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
class SameAsModelComponent extends Component | ||
{ | ||
public function sameMethod(): int | ||
{ | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
class SameAsModelController extends BaseController | ||
{ | ||
/** | ||
* @var array<array-key, string> | ||
*/ | ||
public $components = ['SameAsModel']; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
class SameAsModel extends Model | ||
{ | ||
public function sameMethod(): string | ||
{ | ||
return 'test'; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/Feature/data/existing_controller_component_from_parent_controller.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
/** @var SameAsModelController $controller */ | ||
$component = $controller->Basic; | ||
|
||
assertType('BasicComponent', $component); |
10 changes: 10 additions & 0 deletions
10
tests/Feature/data/existing_controller_component_with_same_method_name_as_model.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
/** @var SameAsModelController $controller */ | ||
$component = $controller->SameAsModel->sameMethod(); | ||
|
||
assertType('int', $component); |