Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
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 ...
Valery's user avatar
  • 1
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'] ); ...
francis astin's user avatar
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 ...
Cardinal System's user avatar
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 *...
Slava.In's user avatar
  • 931
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::...
Alexandre Tranchant's user avatar
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 ...
Shahadat Hossain's user avatar
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'; ...
AbdullahEmin's user avatar
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 ...
Sergey Bakotin's user avatar
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 ...
Matthijs's user avatar
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 ...
Grizzly's user avatar
  • 385
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(...
Martin Komischke's user avatar
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 ...
user21167050's user avatar
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 ...
JacobTheDev's user avatar
  • 18.1k
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 ...
maples's user avatar
  • 218
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: $...
Elikill58's user avatar
  • 4,497

15 30 50 per page
1
2 3 4 5
37