Skip to content

Commit b847d7d

Browse files
committed
add property hook
1 parent 403c9e9 commit b847d7d

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

snippet/float_.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
use PhpParser\Node\Scalar\Float_;
66

7-
return new Float_(100);
7+
return new Float_(100.5);

snippet/php_84/property_hook.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpParser\Modifiers;
6+
7+
$propertyItem = new \PhpParser\Node\PropertyItem('someProperty');
8+
$property = new \PhpParser\Node\Stmt\Property(Modifiers::PUBLIC, [$propertyItem]);
9+
10+
$plus = new \PhpParser\Node\Expr\BinaryOp\Plus(
11+
new \PhpParser\Node\Expr\Variable('variable'),
12+
new \PhpParser\Node\Scalar\Int_(100)
13+
);
14+
15+
$getPropertyHook = new \PhpParser\Node\PropertyHook('getProperty', $plus);
16+
17+
$property->hooks[] = $getPropertyHook;
18+
19+
return $property;

src/NodeCodeSampleProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
final class NodeCodeSampleProvider
1414
{
15-
private Standard $standardPrinter;
15+
private readonly Standard $standardPrinter;
1616

1717
public function __construct(
1818
) {

0 commit comments

Comments
 (0)