33namespace Entity \Collection ;
44
55use Entity \Node \ClassProperty ;
6+ use Entity \Node \ClassData ;
67
7- class PropertiesCollection {
8-
9- public function __construct ($ class ){
8+ class PropertiesCollection
9+ {
10+ public function __construct ($ class )
11+ {
1012 $ this ->class = $ class ;
1113 }
12- public function add (ClassProperty $ prop ){
14+ public function add (ClassProperty $ prop )
15+ {
1316 $ this ->map [$ prop ->name ] = $ prop ;
1417 }
15- public function all (Specification $ spec = null ){
16- if ($ spec === null ){
18+ public function all (Specification $ spec = null )
19+ {
20+ if ($ spec === null ) {
1721 $ spec = new Specification ;
1822 }
1923 $ props = [];
20- foreach ($ this ->map AS $ prop ){
21- if (!$ spec ->satisfy ($ prop )){
24+ foreach ($ this ->map as $ prop ) {
25+ if (!$ spec ->satisfy ($ prop )) {
2226 continue ;
2327 }
2428 $ props [$ prop ->name ] = $ prop ;
2529 }
2630 $ parent = $ this ->class ->getParent ();
27- if ($ parent instanceof ClassData){
31+ if ($ parent instanceof ClassData) {
2832 $ props = array_merge (
2933 $ parent ->properties ->all (new Specification (
3034 $ spec ->getParentMode (),
@@ -34,24 +38,26 @@ public function all(Specification $spec = null){
3438 $ props
3539 );
3640 }
37- sort ($ props );
41+ ksort ($ props );
3842 return $ props ;
3943 }
40- public function get ($ propName , Specification $ spec = null ){
41- if ($ spec === null ){
44+ public function get ($ propName , Specification $ spec = null )
45+ {
46+ if ($ spec === null ) {
4247 $ spec = new Specification ('private ' , 2 , false );
4348 }
44- if (array_key_exists ($ propName , $ this ->map )){
49+ if (array_key_exists ($ propName , $ this ->map )) {
4550 $ prop = $ this ->map [$ propName ];
46- if ($ spec ->satisfy ($ prop )){
51+ if ($ spec ->satisfy ($ prop )) {
4752 return $ prop ;
4853 }
4954 return null ;
5055 }
5156 $ parent = $ this ->class ->getParent ();
52- if ($ parent instanceof ClassData){
57+ if ($ parent instanceof ClassData) {
5358 return $ parent ->properties ->get (
54- $ name , new Specifiaction (
59+ $ propName ,
60+ new Specification (
5561 $ spec ->getParentMode (),
5662 $ spec ->isStatic (),
5763 $ spec ->isMagic ()
@@ -61,5 +67,6 @@ public function get($propName, Specification $spec = null){
6167 }
6268
6369 private $ map = [];
70+ /** @var ClassData */
6471 private $ class ;
6572}
0 commit comments