Skip to content

Commit 387af51

Browse files
Merge pull request #27 from quant-php/dev
Dev
2 parents a176e6e + a9c1a01 commit 387af51

File tree

9 files changed

+39
-15
lines changed

9 files changed

+39
-15
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
# quant-php/quant
1+
# quant<sup>php</sup>
2+
all-purpose library for a general-purpose scripting language.
23

4+
quant is a library for PHP >= 8.2. It is a result of [conjoon](https://conjoon.org) and several other open / closed
5+
source projects, where functionality has proven useful to justify a refactoring into a shared library.
36

4-
## Installation
7+
## Installation
58

69
```bash
710
$ composer require quant-php/quant
8-
```
11+
```
12+
13+
## Documentation
14+
The docs for the project can be found at https://quant-php.dev.
15+

composer.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<testsuite name="Quant Test Suite">
1414
<directory>./src/Quant/Core/Tests/</directory>
1515
</testsuite>
16+
<testsuite name="PHPStan Test Suite">
17+
<directory>./src/Quant/PHPStan/Tests/</directory>
18+
</testsuite>
1619
</testsuites>
1720

1821
<php>

src/Quant/Core/Tests/Trait/AccessorTraitTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,24 @@ public function testSettersAndGettersForClass(): void
7474

7575
$this->assertSame("foo", $inst->getFoo());
7676
$this->assertSame("bar", $inst->getBar());
77-
$this->assertSame("snafu", $inst->getSnafu());
7877
$this->assertSame("foobar", $inst->getFoobar());
7978
}
8079

8180

81+
public function testGetSnafuModifierOverridden(): void
82+
{
83+
$inst = $this->createClassWithSetterAndGetterAttributes([
84+
"foo" => "Hello World",
85+
"bar" => "World Hello"
86+
]);
87+
88+
$this->expectException(BadMethodCallException::class);
89+
90+
/* @phpstan-ignore-next-line */
91+
$inst->getSnafu();
92+
}
93+
94+
8295
public function testAccessorTraitWithDifferentValues(): void
8396
{
8497
$this->expectException(ValueError::class);

src/Quant/Core/Tests/Trait/Resources/ClassHasAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ClassHasAttributes
2727
#[Setter]
2828
public string $foobar = "Ok";
2929

30-
#[Getter]
30+
#[Getter(Modifier::PRIVATE)]
3131
private string $snafu;
3232

3333
public function __construct(

src/Quant/Core/Trait/AccessorTrait.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,9 @@ private function cachePropertiesWithAccessorAttribute(string $accessorClass): ar
245245
continue;
246246
}
247247

248-
$accessorAttribute = $classAccessorAttribute;
249-
248+
$accessorAttribute = $property->getAttributes($accessorClass);
250249
if (empty($accessorAttribute)) {
251-
$accessorAttribute = $property->getAttributes($accessorClass);
250+
$accessorAttribute = $classAccessorAttribute;
252251
}
253252

254253
if (!empty($accessorAttribute) && ($property instanceof ReflectionProperty)) {

src/Quant/PHPStan/Reflection/QuantAccessorMethodReflectionExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ protected function getPropertyConfig(ClassReflection $classReflection, string $m
132132
return null;
133133
}
134134

135-
if (empty($classAttributes)) {
136-
$attributes = $reflectionProperty->getAttributes($prefix === "set" ? Setter::class : Getter::class);
137-
} else {
135+
$attributes = $reflectionProperty->getAttributes($prefix === "set" ? Setter::class : Getter::class);
136+
137+
if (empty($attributes)) {
138138
$attributes = $classAttributes;
139139
}
140140

src/Quant/PHPStan/Tests/Data/D.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ class D
2626

2727
private string $foo;
2828

29+
#[Setter(Modifier::PRIVATE)]
2930
private string $bar;
3031
}

src/Quant/PHPStan/Tests/Reflection/QuantAccessorMethodReflectionExtensionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function testRule(): void
5252
]);
5353

5454
$this->analyse([__DIR__ . "../../Data/ChildD.php"], [
55+
["Call to private method setBar() of class Quant\PHPStan\Tests\Data\D.", 27]
5556
]);
5657
}
5758
}

0 commit comments

Comments
 (0)