FAQ
Hi internals,

someone in the "Return Type Hinting for Methods RFC" thread had the idea
of a "numeric" type hint. I will capture this idea and propose a
"scalar" type hint. I understand the problem of the current discussion
about scalar type hints(int, float, string, double, ...). But there
should be a possibility to define a "scalar" type hint to restrict
arguments to scalar types.

function setName(scalar $name) {}

class Foo {
public function __toString() {}
}

setName(1) // pass
setName(true) //pass
setName('Christian') // pass
setName(new Foo) // pass
setName(array()) //fail
setName(new stdClass) //fail

Why this isn't possible?

Christian

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 3 | next ›
Discussion Overview
groupphp-internals @
categoriesphp
postedDec 22, '11 at 7:52p
activeDec 22, '11 at 8:05p
posts3
users3
websitephp.net

People

Translate

site design / logo © 2022 Grokbase