All Questions
554
questions
0
votes
0
answers
19
views
Problem with the error message displayed in a form
I would like the user to take into account in the form that the numbers are entered with periods and not with commas and I have a problem: the error message is displayed when entering a decimal number ...
1
vote
0
answers
30
views
When using WC_Product_Variable, it creates a simple product [duplicate]
I am trying to progmatticly create a Variable Product in WooCommerce like so:
$currentProduct = new WC_Product_Variable();
$currentProduct->set_name( $product['Title'] );
...
0
votes
1
answer
47
views
Can I check if ReflectionType is instance of another type?
I want to check if a callable's return type is an instance of another type. For example, let's say I a have:
A class Pigeon which extends Animal.
A function addSupplier() which takes a callable ...
3
votes
1
answer
174
views
PHP FFI - Convert PHP array to C pointers array
I have a C function with the following signature. It accepts (from my humble C understanding) an array of C strings and returns a pointer to a random string.
const char *get_random(const char *const *...
1
vote
0
answers
49
views
How to typehint this Generator?
My data provider is sending arrays. The first element is always a string, the second one an array of Token.
public static function dataProvider(): Generator
{
yield ['15', [new Token(15, Lexer::...
2
votes
1
answer
93
views
Allow displaying a custom coupon type in WooCommerce admin coupons list
I have added a new option in the Coupon type select field WooCommerce coupon single page.
Now I want to show that option below the Coupon type column of all coupon page.
The value is being saved in ...
0
votes
1
answer
51
views
Remove type declaration to match parent
I am preparing a PHP.doc and I have a code like this.
/**
* The name and signature of the console command.
*
* @var string
*/
protected string $signature = 'signature';
...
0
votes
1
answer
43
views
To what data type group belongs callable and iterable in php?
In php we have some native data types, like:
Scalar Data Types: integer, string, Floating-Point Numbers or
Doubles, Boolean
Composite Data Type: array, object
Special Data Types: Null, resource, in ...
0
votes
2
answers
127
views
Consistently iterate API response which may be an object or an array of objects
I have the following JSON code.
{
"Artikelnr":"1000",
"Vooraad_NL":2.0,
"Voorraad_DE":1.0,
"Voorraad_BE":0.0
}
When I loop through the json ...
1
vote
2
answers
95
views
What really are scalar and compound data types in PHP?
I know that an array and an object are composites, because more than one value can be stored in them, while scalars are "primitive" data, i.e. a single value.
But are compound types really ...
2
votes
2
answers
562
views
Can I ommit the strict parameter in PHP in_array() when all objects are of the same type?
I use PHP's in_array() function.
The following PHP code example:
<?php
$basket = [ 'apple', 'pear', 'banana' ];
if (!in_array('raspberry', $basket)) {
$basket[] = 'raspberry';
}
var_dump(...
0
votes
0
answers
101
views
PHP Fatal error: Duplicate type false is redundant in PHP 8.1
A PHP fatal error has occurred in php 8.1 with the above php error message for the following section of code. Would anyone have any suggestions on what part could be changed to eliminate the above ...
2
votes
4
answers
1k
views
How can I document types in a multidimensional array to fix type hinting?
I have some template files that have default arguments defined at the top of each file. I can't get type hinting for these values to work correctly; it just says there is no reference. I am including ...
0
votes
1
answer
221
views
PhpStorm inferring `mixed` type on my typed properties
I've been working recently with classes that initialize themselves from an array of data, and have typed properties which are set with values retrieved from the array.
The properties are typed, which ...
0
votes
2
answers
51
views
How to use array as ... type? [duplicate]
I want to call a method like that:
public function to(Address|string ...$addresses) {}
I can call it with $obj->to("my-address"). But, when I want to give a list of address, I'm using:
$...