summaryrefslogtreecommitdiff
path: root/documentation/parameters.html
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-06 09:07:51 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-06 09:07:51 +0100
commit663a646941e855d22b931254b8950b56bd10fc15 (patch)
treec551f5f1963f0605d52ba45d08f0149e810ab9a7 /documentation/parameters.html
parent101378b3f5723ef9efc9ce93666faa310b2295f9 (diff)
parentb5ad08bc621f63caac89070aff8182d0eea87088 (diff)
changes to documentation
Diffstat (limited to 'documentation/parameters.html')
-rw-r--r--documentation/parameters.html23
1 files changed, 13 insertions, 10 deletions
diff --git a/documentation/parameters.html b/documentation/parameters.html
index daaf73c..b40bd5b 100644
--- a/documentation/parameters.html
+++ b/documentation/parameters.html
@@ -3,8 +3,9 @@
PHP has a mechanism to enforce the types of function parameters, and to accept
parameters either by reference or by value. In the <a href="functions">
earlier examples</a>, we had not yet used that mechanism, and we left it to
- the function implementations to inspect the 'Php::Parameters' object, and to
- check whether the number of parameters were correct, and of the right type.
+ the function implementations to inspect the 'Php::Parameters' object (which
+ is a std::vector of Php::Value objects), and to check whether the number of
+ parameters is correct, and of the right type.
</p>
<p>
However, the 'Extension::add()' method takes a third optional parameter that
@@ -32,7 +33,7 @@ extern "C" {
}</pre></code>
</p>
<p>
- Above you see that we passed in additional information when we registered the
+ Above you see that we pass in additional information when we register the
"example" function. We tell the PHP engine that our function accepts three parameters:
the first parameter must be numeric, while the other ones are
instances of type "ExampleClass" and "OtherClass". In the end, your native C++
@@ -43,9 +44,10 @@ extern "C" {
</p>
<h2>Can you really enforce scalar parameters?</h2>
<p>
- In PHP there is no way to enforce the type of a scalar parameter. When you
- write a function in PHP, it is possible to enforce that the function receives
- an object of a certain type, or an array, but not that you want to receive
+ You may be surprised to see that we specified the first parameter to be of
+ type Numeric. After all, in PHP there is no offical way to enforce the type of a
+ scalar parameter. When you write a function in PHP, it is possible to enforce
+ that the function receives an object or an array, but not that you want to receive
a string or an integer.
</p>
<p>
@@ -73,13 +75,14 @@ function example3(int $param)
</code></pre>
</p>
<p>
- The same is true for native functions. Although the core PHP engine offers
- the possibility to specify that your function only accepts parameters of type
+ The same is true for native functions. Although the core PHP engine and PHP-CPP
+ library both offer the possibility to specify that your function accepts parameters of type
"Php::Type::Numeric" or of type "Php::Type::String", this setting is further
completely ignored. Maybe this is going to change in the
future (let's hope so), but for now it is only meaningful to specify the
parameter type for objects and arrays. We have however chosen to still offer
- this feature in PHP-CPP to be ready for future versions of PHP.
+ this feature in PHP-CPP to be ready for future versions of PHP, but for now
+ the specification of the numeric parameter in our example is meaningless.
</p>
<p>
To come back to our example, the following functions calls can now be done
@@ -108,7 +111,7 @@ example("x", "y", "z");
</p>
<p>
The PHP engine will trigger an error if your function is called with wrong
- parameters, and will not make the call to your function.
+ parameters, and will not make the actual call to the native function.
</p>
<h2>The Php::ByVal class further explained</h2>
<p>