Hi!

I'm sorry but I have no idea what you're talking about there =\ PHP
has a bunch of different types, the current type hinting (typechecking

"int" is a different kind of type from Zend_Controller_Factory and SimpleXML - the same kind of types are "int" and "object". The former are engine types (IS_INTEGER, IS_OBJECT), the latter are classes.

I very much can, it's just not my intention. I want to be able to use
type hinting/type checking as a sanity check. If I write a method
whose signature is foo(int $n) I signal my intention to only accept

Then you should use statically typed language. There's no law saying every code on the planet should be written in PHP, and PHP is not a statically typed language. So by bolting static typing onto it you are using wrong tool for the job.

If PHP was meant to prevent programmers from controlling the type of
their variables then I'm afraid there's been a misunderstanding and

PHP and dynamic languages in general are not preventing people from knowing the types of variables, they however remove a number of annoyances that come with static types. You want to bring all those back - and that without the benefits that are compensating for those annoyances in compiled languages - meaning being sure upfront that the code always gets proper data in proper places. You don't know that unless you statically type and compile your whole code - so you just traded flexibility and API agility for nothing.

I'm not sure what you meant by "objects of classes can not [be
converted into another type]". Arrays can be cast as booleans (false

There are no generic rules that allow conversion between two classes - such as SimpleXML and Exception, for example. In general, conversions between classes don't happen in the engine. Conversion between IS_* types happen all the time.

TL;DR: I always thought PHP would help me control the type of my
variables instead of forcing my userland code to mirror PHP's internal
functions.

If you want strict typing ("control the type of my variables") I'm afraid you're using not only wrong language but wrong paradigm. You should be using statically typed language. Try C# or Java or Scala or something like that. Just having parameter typing won't help you - you'd just kick the problem around the code, it will be now it variables upstream, etc.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to