Skip to content

Commit 5d0241b

Browse files
committed
Rename to collections extension, Collections\Deque
https://wiki.php.net/rfc/deque_straw_poll
1 parent 677efc5 commit 5d0241b

38 files changed

+571
-468
lines changed

ext/spl/spl_deque.c renamed to ext/collections/collections_deque.c

Lines changed: 212 additions & 213 deletions
Large diffs are not rendered by default.

ext/spl/spl_deque.h renamed to ext/collections/collections_deque.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
+----------------------------------------------------------------------+
1515
*/
1616

17-
#ifndef TEDS_DEQUE_H
18-
#define TEDS_DEQUE_H
17+
#ifndef COLLECTIONS_DEQUE_H
18+
#define COLLECTIONS_DEQUE_H
1919

20-
extern zend_class_entry *spl_ce_Deque;
20+
extern zend_class_entry *collections_ce_Deque;
2121

22-
PHP_MINIT_FUNCTION(spl_deque);
22+
PHP_MINIT_FUNCTION(collections_deque);
2323

24-
#endif /* TEDS_DEQUE_H */
24+
#endif /* COLLECTIONS_DEQUE_H */

ext/spl/spl_deque.stub.php renamed to ext/collections/collections_deque.stub.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
/** @generate-class-entries */
44

5+
namespace Collections;
6+
57
/**
68
* A double-ended queue (Typically abbreviated as Deque, pronounced "deck", like "cheque")
79
* represented internally as a circular buffer.
@@ -30,7 +32,7 @@ public function __construct(iterable $iterator = []) {}
3032
* position ends up before the start of the Deque at the time iteration resumes.
3133
* - They will not cause the remaining values to be iterated over more than once or skipped.
3234
*/
33-
public function getIterator(): InternalIterator {}
35+
public function getIterator(): \InternalIterator {}
3436
/** Returns the number of elements in the Deque. */
3537
public function count(): int {}
3638
/** Returns true if there are 0 elements in the Deque. */

ext/collections/collections_deque_arginfo.h

Lines changed: 137 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/collections/config.m4

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
PHP_NEW_EXTENSION(collections, php_collections.c collections_deque.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
2+
PHP_INSTALL_HEADERS([ext/spl], [php_collections.h collections_deque.h])
3+
PHP_ADD_EXTENSION_DEP(collections, pcre, true)
4+
PHP_ADD_EXTENSION_DEP(collections, spl, true)
5+
PHP_ADD_EXTENSION_DEP(collections, standard, true)
6+
PHP_ADD_EXTENSION_DEP(collections, json)

ext/collections/config.w32

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// vim:ft=javascript
2+
3+
EXTENSION("collections", "php_collections.c collections_deque.c", false /*never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
4+
PHP_COLLECTIONS="yes";
5+
PHP_INSTALL_HEADERS("ext/collections", "php_collections.h collections_deque.h");

ext/collections/php_collections.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| collections extension for PHP |
4+
| See COPYING file for further copyright information |
5+
+----------------------------------------------------------------------+
6+
| Author: Tyson Andre <tandre@php.net> |
7+
+----------------------------------------------------------------------+
8+
*/
9+
10+
#ifdef HAVE_CONFIG_H
11+
# include "config.h"
12+
#endif
13+
14+
#include "php.h"
15+
16+
#include "ext/standard/info.h"
17+
18+
#include "collections_deque.h"
19+
20+
#include "php_collections.h"
21+
22+
/* {{{ PHP_MINIT_FUNCTION */
23+
PHP_MINIT_FUNCTION(collections)
24+
{
25+
PHP_MINIT(collections_deque)(INIT_FUNC_ARGS_PASSTHRU);
26+
return SUCCESS;
27+
}
28+
/* }}} */
29+
30+
/* {{{ PHP_MINFO_FUNCTION */
31+
PHP_MINFO_FUNCTION(collections)
32+
{
33+
(void) ((ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU));
34+
php_info_print_table_start();
35+
php_info_print_table_header(2, "collections support", "enabled");
36+
php_info_print_table_row(2, "collections version", PHP_COLLECTIONS_VERSION);
37+
php_info_print_table_end();
38+
}
39+
/* }}} */
40+
41+
/* {{{ collections_module_entry */
42+
zend_module_entry collections_module_entry = {
43+
STANDARD_MODULE_HEADER,
44+
"collections", /* Extension name */
45+
NULL, /* zend_function_entry */
46+
PHP_MINIT(collections), /* PHP_MINIT - Module initialization */
47+
NULL, /* PHP_MSHUTDOWN - Module shutdown */
48+
NULL, /* PHP_RINIT - Request initialization */
49+
NULL, /* PHP_RSHUTDOWN - Request shutdown */
50+
PHP_MINFO(collections), /* PHP_MINFO - Module info */
51+
PHP_COLLECTIONS_VERSION, /* Version */
52+
STANDARD_MODULE_PROPERTIES
53+
};
54+
/* }}} */
55+
56+
57+
#ifdef COMPILE_DL_COLLECTIONS
58+
# ifdef ZTS
59+
ZEND_TSRMLS_CACHE_DEFINE()
60+
# endif
61+
ZEND_GET_MODULE(collections)
62+
#endif

ext/collections/php_collections.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| Copyright (c) The PHP Group |
4+
+----------------------------------------------------------------------+
5+
| This source file is subject to version 3.01 of the PHP license, |
6+
| that is bundled with this package in the file LICENSE, and is |
7+
| available through the world-wide-web at the following url: |
8+
| https://www.php.net/license/3_01.txt |
9+
| If you did not receive a copy of the PHP license and are unable to |
10+
| obtain it through the world-wide-web, please send a note to |
11+
| license@php.net so we can mail you a copy immediately. |
12+
+----------------------------------------------------------------------+
13+
| Authors: Tyson Andre <tandre@php.net> |
14+
+----------------------------------------------------------------------+
15+
*/
16+
17+
#ifndef PHP_COLLECTIONS_H
18+
#define PHP_COLLECTIONS_H
19+
20+
#include "php.h"
21+
#include <stdarg.h>
22+
23+
#define PHP_COLLECTIONS_VERSION PHP_VERSION
24+
25+
extern zend_module_entry collections_module_entry;
26+
#define phpext_collections_ptr &collections_module_entry
27+
28+
PHP_MINIT_FUNCTION(collections);
29+
PHP_MINFO_FUNCTION(collections);
30+
31+
#endif /* PHP_COLLECTIONS_H */

ext/spl/tests/Deque/Deque.phpt renamed to ext/collections/tests/Deque/Deque.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
--TEST--
2-
Deque constructed from array
2+
Collections\Deque constructed from array
33
--FILE--
44
<?php
55
// discards keys
6-
$it = new Deque(['first' => 'x', 'second' => new stdClass()]);
6+
$it = new Collections\Deque(['first' => 'x', 'second' => new stdClass()]);
77
foreach ($it as $key => $value) {
88
printf("Key: %s\nValue: %s\n", var_export($key, true), var_export($value, true));
99
}
1010
var_dump($it);
1111
var_dump((array)$it);
1212

13-
$it = new Deque([]);
13+
$it = new Collections\Deque([]);
1414
var_dump($it);
1515
var_dump((array)$it);
1616
foreach ($it as $key => $value) {
@@ -24,7 +24,7 @@ Value: 'x'
2424
Key: 1
2525
Value: (object) array(
2626
)
27-
object(Deque)#1 (2) {
27+
object(Collections\Deque)#1 (2) {
2828
[0]=>
2929
string(1) "x"
3030
[1]=>
@@ -38,7 +38,7 @@ array(2) {
3838
object(stdClass)#2 (0) {
3939
}
4040
}
41-
object(Deque)#3 (0) {
41+
object(Collections\Deque)#3 (0) {
4242
}
4343
array(0) {
4444
}

ext/spl/tests/Deque/aggregate.phpt renamed to ext/collections/tests/Deque/aggregate.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
--TEST--
2-
Deque is an IteratorAggregate
2+
Collections\Deque is an IteratorAggregate
33
--FILE--
44
<?php
55

6-
$it = new Deque(['discarded_first' => 'x', 'discardedsecond' => (object)['key' => 'value']]);
6+
$it = new Collections\Deque(['discarded_first' => 'x', 'discardedsecond' => (object)['key' => 'value']]);
77
foreach ($it as $k1 => $v1) {
88
foreach ($it as $k2 => $v2) {
99
printf("k1=%s k2=%s v1=%s v2=%s\n", json_encode($k1), json_encode($k2), json_encode($v1), json_encode($v2));

ext/spl/tests/Deque/arrayCast.phpt renamed to ext/collections/tests/Deque/arrayCast.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
--TEST--
2-
Deque to array
2+
Collections\Deque to array
33
--FILE--
44
<?php
55
// discards keys
6-
$it = new Deque([strtoupper('test')]);
6+
$it = new Collections\Deque([strtoupper('test')]);
77
var_dump((array)$it);
88
$it[0] = strtoupper('test2');
99
var_dump((array)$it);
@@ -22,9 +22,9 @@ array(1) {
2222
[0]=>
2323
string(5) "TEST2"
2424
}
25-
object(Deque)#1 (1) {
25+
object(Collections\Deque)#1 (1) {
2626
[0]=>
2727
string(5) "TEST2"
2828
}
29-
object(Deque)#1 (0) {
29+
object(Collections\Deque)#1 (0) {
3030
}

ext/spl/tests/Deque/clear.phpt renamed to ext/collections/tests/Deque/clear.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
--TEST--
2-
Deque clear
2+
Collections\Deque clear
33
--FILE--
44
<?php
55

6-
$it = new Deque(['first' => new stdClass()]);
6+
$it = new Collections\Deque(['first' => new stdClass()]);
77
var_dump($it->toArray());
88
printf("count=%d\n", $it->count());
99
$it->clear();

ext/spl/tests/Deque/clone.phpt renamed to ext/collections/tests/Deque/clone.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
--TEST--
2-
Deque can be cloned
2+
Collections\Deque can be cloned
33
--FILE--
44
<?php
55

6-
$it = new Deque([new stdClass(), new ArrayObject()]);
6+
$it = new Collections\Deque([new stdClass(), new ArrayObject()]);
77
$it2 = clone $it;
88
unset($it);
99
foreach ($it2 as $key => $value) {

ext/spl/tests/Deque/exceptionhandler.phpt renamed to ext/collections/tests/Deque/exceptionhandler.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Deque constructed from Traversable throwing
2+
Collections\Deque constructed from Traversable throwing
33
--FILE--
44
<?php
55

@@ -21,7 +21,7 @@ function yields_and_throws() {
2121
echo "Unreachable\n";
2222
}
2323
try {
24-
$it = new Deque(yields_and_throws());
24+
$it = new Collections\Deque(yields_and_throws());
2525
} catch (RuntimeException $e) {
2626
echo "Caught " . $e->getMessage() . "\n";
2727
}

0 commit comments

Comments
 (0)