Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ func process_data_packed(arr *C.zend_array) unsafe.Pointer {
- `frankenphp.GoAssociativeArray(arr unsafe.Pointer, ordered bool) frankenphp.AssociativeArray` - Convert a PHP array to an ordered Go `AssociativeArray` (map with order)
- `frankenphp.GoMap(arr unsafe.Pointer) map[string]any` - Convert a PHP array to an unordered Go map
- `frankenphp.GoPackedArray(arr unsafe.Pointer) []any` - Convert a PHP array to a Go slice
- `frankenphp.IsPacked(zval *C.zend_array) bool` - Check if a PHP array is packed (indexed only) or associative (key-value pairs)

### Working with Callables

Expand Down
1 change: 1 addition & 0 deletions docs/fr/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ func process_data_packed(arr *C.zval) unsafe.Pointer {
- `frankenphp.GoAssociativeArray(arr unsafe.Pointer, ordered bool) frankenphp.AssociativeArray` - Convertir un tableau PHP vers un `AssociativeArray` Go ordonné (map avec ordre)
- `frankenphp.GoMap(arr unsafe.Pointer) map[string]any` - Convertir un tableau PHP vers une map Go non ordonnée
- `frankenphp.GoPackedArray(arr unsafe.Pointer) []any` - Convertir un tableau PHP vers un slice Go
- `frankenphp.IsPacked(zval *C.zend_array) bool` - Vérifie si le tableau PHP est une liste ou un tableau associatif

### Travailler avec des Callables

Expand Down
10 changes: 10 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,16 @@ func createNewArray(size uint32) *C.zend_array {
return (*C.zend_array)(unsafe.Pointer(arr))
}

// IsPacked determines if the given zend_array is a packed array (list).
// Returns false if the array is nil or not packed.
func IsPacked(arr unsafe.Pointer) bool {
if arr == nil {
return false
}

return htIsPacked((*C.zend_array)(arr))
}

// htIsPacked checks if a zend_array is a list (packed) or hashmap (not packed).
func htIsPacked(ht *C.zend_array) bool {
flags := *(*C.uint32_t)(unsafe.Pointer(&ht.u[0]))
Expand Down