|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-10-29 07:11 UTC] krakjoe@php.net
-Status: Open
+Status: Closed
-Package: Feature/Change Request
+Package: *General Issues
-Assigned To:
+Assigned To: krakjoe
[2013-10-29 07:11 UTC] krakjoe@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Jun 18 02:00:01 2026 UTC |
Description: ------------ It'll be very useful to add the ability to cast an object to a parent class. A simple example could be security: having a base class with attributes, is extended by another that can do CRUD operations on DB. When passing to VIEW layer (according to MVC), just do a cast to base object, and CRUD actions will be disabled. Reproduce code: --------------- class Person { protected $age; function getAge() { return $this->age; } function setAge($age) {$this->age = $age; } } class PersonDB extends person { function load($id) { // SQL execution $this->setAge($resultSet->age); } } in Model layer: $objPersonDB = new PersonDB(); $objPersonDB->load($id); in Controller layer, sends $person to View layer: $person = (Person)$objPersonDB; Expected result: ---------------- if I call, in View layer: $person->load(5); must raise an error Actual result: -------------- cast do nothing, method is invoked.