Php POO Flashcards

1
Q

3 ways to call a static method (class Foo, method bar)

A
1.
$foo = new Foo;
$foo::bar();
2.
$foo = 'Foo'
$foo::bar();
3.
Foo::bar();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Rules about method override

A
  1. Visibility: Same or less restrictiv
  2. Same number of required argument.
  3. Same signature (same type of arguments, same return value)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

method __construct can be declared in … (3)

A
  1. class
  2. interface
  3. abstract class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Rules about constants declared in interface

A

Can not be overriden

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Precedence order of trait and inheritance

A
class A{ function a(A) {}} 
trait T { function a(T) {}} 
class B extends A{ use T;}
class C extends A{ use T;  function a() {C}}
C::a() -> C
B::a() -> T
A::a() -> A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to access parent of class A which use trait T in T

A

In T, using “parent::” allows to access the parent of any class using the trait.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

foreach of an object without the Iterable or the IteratorAgregate interface.
What happens?

A

Iterate through all public argument.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to do a quick collection? (2)

A
  1. Implement IteratorAggregate and return the array wrapped in an ArrayIterator
  2. Implement Iterable and use the function current(), key(), reset(), next() in the method with the same names
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to do a quick collection? (2)

A
  1. Implement IteratorAggregate and return the array wrapped in an ArrayIterator
  2. Implement Iterable and use the function current(), key(), reset(), next() in the method with the same names
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How need to be declared the __construct of a class inheriting from one declaring an abstract __construct?

A

For the first __construct in te hierarchy which is not abstract, the same as signature (same rules as method override). After, anyhow

How well did you know this?
1
Not at all
2
3
4
5
Perfectly