Skip to content

Commit 71baeef

Browse files
authored
add contract interface (#5)
* add contract interface * misc
1 parent c8dcab7 commit 71baeef

File tree

5 files changed

+33
-30
lines changed

5 files changed

+33
-30
lines changed

src/ClassPropertyExtension/AbstractClassPropertyExtension.php

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
use PHPStan\Reflection\PropertiesClassReflectionExtension;
99
use PHPStan\Reflection\PropertyReflection;
1010
use PHPStan\Reflection\ReflectionProvider;
11+
use PHPStanCakePHP2\Contract\PropertyNameExtensionInterface;
1112
use PHPStanCakePHP2\Reflection\PublicReadOnlyPropertyReflection;
1213

13-
abstract class AbstractClassPropertyExtension implements PropertiesClassReflectionExtension
14+
abstract class AbstractClassPropertyExtension implements PropertiesClassReflectionExtension, PropertyNameExtensionInterface
1415
{
1516
private ReflectionProvider $reflectionProvider;
1617

@@ -42,26 +43,4 @@ public function getProperty(
4243

4344
return new PublicReadOnlyPropertyReflection($correctedPropertyName, $classReflection);
4445
}
45-
46-
/**
47-
* @todo use constract instead to separate
48-
* Get the class name of the type of property.
49-
*/
50-
abstract protected function getPropertyParentClassName(): string;
51-
52-
/**
53-
* @todo use constract instead to separate
54-
* Get the class names which can contain the property.
55-
*
56-
* @return array<string>
57-
*/
58-
abstract protected function getContainingClassNames(): array;
59-
60-
/**
61-
* @todo use constract instead to separate
62-
* Return the class name from the property name.
63-
*/
64-
abstract protected function getClassNameFromPropertyName(
65-
string $propertyName
66-
): string;
6746
}

src/ClassPropertyExtension/ClassModelsPropertyExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
*/
1010
final class ClassModelsPropertyExtension extends AbstractClassPropertyExtension
1111
{
12-
protected function getPropertyParentClassName(): string
12+
public function getPropertyParentClassName(): string
1313
{
1414
return 'Model';
1515
}
1616

1717
/**
1818
* @return array<string>
1919
*/
20-
protected function getContainingClassNames(): array
20+
public function getContainingClassNames(): array
2121
{
2222
return [
2323
'Controller',
@@ -26,7 +26,7 @@ protected function getContainingClassNames(): array
2626
];
2727
}
2828

29-
protected function getClassNameFromPropertyName(
29+
public function getClassNameFromPropertyName(
3030
string $propertyName
3131
): string {
3232
return $propertyName;

src/ClassPropertyExtension/ShellClassPropertyExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@
1111
*/
1212
final class ShellClassPropertyExtension extends AbstractClassPropertyExtension
1313
{
14-
protected function getPropertyParentClassName(): string
14+
public function getPropertyParentClassName(): string
1515
{
1616
return 'Shell';
1717
}
1818

1919
/**
2020
* @return array<string>
2121
*/
22-
protected function getContainingClassNames(): array
22+
public function getContainingClassNames(): array
2323
{
2424
return ['Shell'];
2525
}
2626

27-
protected function getClassNameFromPropertyName(
27+
public function getClassNameFromPropertyName(
2828
string $propertyName
2929
): string {
3030
return $propertyName . 'Task';
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PHPStanCakePHP2\Contract;
6+
7+
interface PropertyNameExtensionInterface
8+
{
9+
/**
10+
* Get the class name of the type of property.
11+
*/
12+
public function getPropertyParentClassName(): string;
13+
14+
/**
15+
* Get the class names which can contain the property.
16+
*
17+
* @return string[]
18+
*/
19+
public function getContainingClassNames(): array;
20+
21+
/**
22+
* Return the class name from the property name.
23+
*/
24+
public function getClassNameFromPropertyName(string $propertyName): string;
25+
}

tests/config/phpstan.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ parameters:
22
behaviorPaths:
33
- tests/Source/Model/Behavior/*.php
44

5-
# @todo add exists validatoin to avoid misspaths
65
schemaPaths:
76
- tests/Source/Config/Schema/*.php
87

0 commit comments

Comments
 (0)