Skip to content

Commit fc01de9

Browse files
uestladg
authored andcommitted
only own properties set to class
1 parent b8dfd32 commit fc01de9

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

src/PhpGenerator/ClassType.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ public static function from($from)
103103
}
104104
}
105105
foreach ($from->getProperties() as $prop) {
106-
$class->properties[$prop->getName()] = Property::from($prop);
106+
if ($prop->getDeclaringClass() == $from) { // intentionally ==
107+
$class->properties[$prop->getName()] = Property::from($prop);
108+
}
107109
}
108110
foreach ($from->getMethods() as $method) {
109111
if ($method->getDeclaringClass() == $from) { // intentionally ==
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class B extends A
2+
{
3+
4+
public $d;
5+
6+
protected $e;
7+
8+
private $f;
9+
10+
11+
function bar()
12+
{
13+
14+
}
15+
16+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
use Nette\PhpGenerator\ClassType,
4+
ReflectionClass,
5+
Tester\Assert;
6+
7+
8+
require __DIR__ . '/../bootstrap.php';
9+
10+
11+
class A
12+
{
13+
public $a;
14+
protected $b;
15+
private $c;
16+
17+
function foo() {}
18+
}
19+
20+
21+
class B extends A
22+
{
23+
public $d;
24+
protected $e;
25+
private $f;
26+
27+
function bar() { return 3; }
28+
}
29+
30+
31+
Assert::matchFile(__DIR__ . '/ClassType.inheritance.expect', (string) ClassType::from('B'));

0 commit comments

Comments
 (0)