From f2c2f86a993175ebde3f486a6b9829b96ec18e3c Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Wed, 5 Mar 2014 23:43:55 +0100 Subject: update to documentation --- documentation/parameters.html | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'documentation/parameters.html') diff --git a/documentation/parameters.html b/documentation/parameters.html index daaf73c..9e3c2ec 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 earlier examples, 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.

However, the 'Extension::add()' method takes a third optional parameter that @@ -32,7 +33,7 @@ extern "C" { }

- 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" {

Can you really enforce scalar parameters?

- 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 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.

@@ -79,7 +81,8 @@ function example3(int $param) 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 a numeric parameter is completely pointless.

To come back to our example, the following functions calls can now be done -- cgit v1.2.3 From d3250ebdb03b6140cfa5b2c3111b594a5cda2c69 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Wed, 5 Mar 2014 23:44:26 +0100 Subject: update to documentation --- documentation/parameters.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'documentation/parameters.html') diff --git a/documentation/parameters.html b/documentation/parameters.html index 9e3c2ec..cd3bc23 100644 --- a/documentation/parameters.html +++ b/documentation/parameters.html @@ -45,7 +45,7 @@ extern "C" {

Can you really enforce scalar parameters?

You may be surprised to see that we specified the first parameter to be of - type Numeric. After all, in PHP there is offical way to enforce the type of a + 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. -- cgit v1.2.3 From 4225fc6a2d104d26f6c3c93d87505bcdccd9083d Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Wed, 5 Mar 2014 23:45:11 +0100 Subject: update to documentation --- documentation/parameters.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'documentation/parameters.html') diff --git a/documentation/parameters.html b/documentation/parameters.html index cd3bc23..1bf3d8d 100644 --- a/documentation/parameters.html +++ b/documentation/parameters.html @@ -75,7 +75,7 @@ function example3(int $param)

- The same is true for native functions. Although the core PHP engine offers + The same is true for native functions. Although the core PHP engine and PHP-CPP offers the possibility to specify that your function only 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 -- cgit v1.2.3 From 7048aa3d9b0a140a7b4aaf0b5288a8b6fcaee935 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Wed, 5 Mar 2014 23:45:43 +0100 Subject: update to documentation --- documentation/parameters.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'documentation/parameters.html') diff --git a/documentation/parameters.html b/documentation/parameters.html index 1bf3d8d..35707d2 100644 --- a/documentation/parameters.html +++ b/documentation/parameters.html @@ -75,8 +75,8 @@ function example3(int $param)

- The same is true for native functions. Although the core PHP engine and PHP-CPP 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 only 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 -- cgit v1.2.3 From b5ad08bc621f63caac89070aff8182d0eea87088 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Wed, 5 Mar 2014 23:46:27 +0100 Subject: update to documentation --- documentation/parameters.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'documentation/parameters.html') diff --git a/documentation/parameters.html b/documentation/parameters.html index 35707d2..3711b59 100644 --- a/documentation/parameters.html +++ b/documentation/parameters.html @@ -82,7 +82,7 @@ function example3(int $param) 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, but for now - the specification of a numeric parameter is completely pointless. + the specification of the numeric parameter in our example is pointless.

To come back to our example, the following functions calls can now be done -- cgit v1.2.3