advice on polymorphism Im trying to teach myself enough to start using more OOP in php.  This is what Ive come up with. Is there any reason why any of this is done wrong, or should be done another way?

    class workers {
            private $name;

            function __construct($name){
                $this-&gt;name=$name;
            }


            function setName($name){
                $this-&gt;name=$name;  
            }

            function doPrint($who){
                print $who-&gt;name . ' is ' . $who-&gt;isWhat() .'&lt;br&gt;';

            }

    }

    class boss extends workers{

            function isWhat(){
                return 'the boss';
            }

    }

    class bee extends workers{

            function isWhat(){
                return 'not the boss';
            }
    }


    $theboss =new boss('gordon');   
    $thebee= new bee('johnny');

        workers::doPrint($theboss);
        workers::doPrint($thebee);



    $theboss-&gt;setName('johnny');
    $thebee-&gt;setName('gordon');

        workers::doPrint($theboss);
        workers::doPrint($thebee);


prints:

gordon is the boss
johnny is not the boss
johnny is the boss
gordon is not the boss
you should use an abstract class and an interface. also define the doPrint method as static when you want to call it static.

abstract class worker {

    /*...*/

    public static function doPrint(worker_interface $who) {

        /*...*/
    }
}

interface worker_interface {

    public function isWhat();
    public function setName($name);
}

class boss extends worker implements worker_interface {


    public function isWhat() {

        return 'the boss';
    }
}

class bee extends worker implements worker_interface {


    public function isWhat() {

        return 'not the boss';
    }
}


define the type for all methods you are passing worker instances to like in doPrint

EDIT:

alternatively you could also just add an abstract function instead of using an interface

abstract class worker {

    /*...*/

    public static function doPrint(worker $who) {

        /*...*/
    }

    public abstract function isWhat();
}

class boss extends worker {


    public function isWhat() {

        return 'the boss';
    }
}

class bee extends worker {


    public function isWhat() {

        return 'not the boss';
    }
}