• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

timber / timber / 20695674007

04 Jan 2026 04:14PM UTC coverage: 89.681% (+1.5%) from 88.211%
20695674007

push

travis-ci

nlemoine
test: Fix ancestors post tests

4615 of 5146 relevant lines covered (89.68%)

63.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

35.29
/src/PostArrayObject.php
1
<?php
2

3
namespace Timber;
4

5
use ArrayObject;
6
use JsonSerializable;
7
use ReturnTypeWillChange;
8
use WP_Post;
9

10
/**
11
 * PostArrayObject class for dealing with arbitrary collections of Posts
12
 * (typically not wrapping a `WP_Query` directly, which is what `Timber\PostQuery` does).
13
 *
14
 * @api
15
 */
16
class PostArrayObject extends ArrayObject implements PostCollectionInterface, JsonSerializable
17
{
18
    use AccessesPostsLazily;
19

20
    /**
21
     * Takes an arbitrary array of WP_Posts to wrap and (lazily) translate to
22
     * Timber\Post instances.
23
     *
24
     * @api
25
     * @param WP_Post[] $posts an array of WP_Post objects
26
     */
27
    public function __construct(array $posts)
38✔
28
    {
29
        parent::__construct($posts, 0, PostsIterator::class);
38✔
30
    }
31

32
    /**
33
     * @inheritdoc
34
     */
35
    public function pagination(array $options = [])
2✔
36
    {
37
        return null;
2✔
38
    }
39

40
    /**
41
     * Override data printed by var_dump() and similar. Realizes the collection before
42
     * returning. Due to a PHP bug, this only works in PHP >= 7.4.
43
     *
44
     * @see https://bugs.php.net/bug.php?id=69264
45
     * @internal
46
     */
47
    public function __debugInfo(): array
×
48
    {
49
        return [
×
50
            'info' => \sprintf(
×
51
                '
×
52
********************************************************************************
53

54
    This output is generated by %s().
55

56
    The properties you see here are not actual properties, but only debug
57
    output. If you want to access the actual instances of Timber\Posts, loop
58
        over the collection or get all posts through $query->to_array().
59

60
        More info: https://timber.github.io/docs/v2/guides/posts/#debugging-post-collections
61

62
********************************************************************************',
×
63
                __METHOD__
×
64
            ),
×
65
            'posts' => $this->getArrayCopy(),
×
66
            'factory' => $this->factory,
×
67
            'iterator' => $this->getIterator(),
×
68
        ];
×
69
    }
70

71
    /**
72
     * Returns realized (eagerly instantiated) Timber\Post data to serialize to JSON.
73
     *
74
     * @internal
75
     */
76
    #[ReturnTypeWillChange]
2✔
77
    public function jsonSerialize()
78
    {
79
        return $this->getArrayCopy();
2✔
80
    }
81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc