Skip to content

Commit 5f8ed10

Browse files
committed
improve TargetCustom docs
1 parent 69c343e commit 5f8ed10

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

src/SourceCustom.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function __construct()
2020

2121
/**
2222
* Attach a read handler.
23+
*
2324
* The interface is similar to fread. The handler is given a number
2425
* of bytes to fetch, and should return a bytes-like object containing up
2526
* to that number of bytes. If there is no more data available, it should
@@ -32,16 +33,18 @@ public function onRead(callable $callback): void
3233

3334
/**
3435
* Attach a seek handler.
36+
*
3537
* The interface is the same as fseek, so the handler is passed
3638
* parameters for $offset and $whence with the same meanings.
3739
* However, the handler MUST return the new seek position. A simple way
3840
* to do this is to call ftell() and return that result.
3941
* Seek handlers are optional. If you do not set one, your source will be
4042
* treated as unseekable and libvips will do extra caching.
43+
*
4144
* $whence in particular:
42-
* 0 => start
43-
* 1 => current position
44-
* 2 => end
45+
* - 0 => start
46+
* - 1 => current position
47+
* - 2 => end
4548
*/
4649
public function onSeek(callable $callback): void
4750
{

src/TargetCustom.php

+26-9
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ public function __construct()
2020

2121
/**
2222
* Attach a write handler.
23-
* The interface is exactly as fwrite. The handler is given a bytes-like object to write,
24-
* and should return the number of bytes written.
23+
*
24+
* The interface is similar to fwrite(). The handler is given a
25+
* bytes-like object to write, and should return the number of bytes
26+
* written.
27+
*
28+
* Unlike fwrite, you should return -1 on error.
29+
*
2530
* @throws Exception
2631
*/
2732
public function onWrite(callable $callback): void
@@ -31,10 +36,12 @@ public function onWrite(callable $callback): void
3136

3237
/**
3338
* Attach a read handler.
34-
* The interface is similar to fread. The handler is given a number
39+
*
40+
* The interface is similar to fread(). The handler is given a number
3541
* of bytes to fetch, and should return a bytes-like object containing up
3642
* to that number of bytes. If there is no more data available, it should
3743
* return null.
44+
*
3845
* Read handlers on VipsTarget are optional. If you do not set one, your
3946
* target will be treated as unreadable and libvips will be unable to
4047
* write some file types (just TIFF, as of the time of writing).
@@ -48,16 +55,19 @@ public function onRead(callable $callback): void
4855

4956
/**
5057
* Attach a seek handler.
51-
* The interface is the same as fseek, so the handler is passed
58+
*
59+
* The interface is similar to fseek, so the handler is passed
5260
* parameters for $offset and $whence with the same meanings.
5361
* However, the handler MUST return the new seek position. A simple way
5462
* to do this is to call ftell() and return that result.
63+
*
5564
* Seek handlers are optional. If you do not set one, your source will be
5665
* treated as unseekable and libvips will do extra caching.
66+
*
5767
* $whence in particular:
58-
* 0 => start
59-
* 1 => current position
60-
* 2 => end
68+
* - 0 => start
69+
* - 1 => current position
70+
* - 2 => end
6171
*/
6272
public function onSeek(callable $callback): void
6373
{
@@ -68,9 +78,12 @@ public function onSeek(callable $callback): void
6878

6979
/**
7080
* Attach an end handler.
81+
*
7182
* This optional handler is called at the end of write. It should do any
7283
* cleaning up necessary, and return 0 on success and -1 on error.
73-
* Automatically falls back to onFinish if libvips <8.13
84+
*
85+
* Automatically falls back to onFinish if libvips <8.13.
86+
*
7487
* @throws Exception
7588
*/
7689
public function onEnd(callable $callback): void
@@ -84,8 +97,12 @@ public function onEnd(callable $callback): void
8497

8598
/**
8699
* Attach a finish handler.
87-
* For libvips 8.13 and later, this method is deprecated in favour of @throws Exception
100+
*
101+
* For libvips 8.13 and later, this method is deprecated in favour of
102+
* onEnd().
103+
*
88104
* @see TargetCustom::onEnd()
105+
* @throws Exception
89106
*/
90107
public function onFinish(callable $callback): void
91108
{

0 commit comments

Comments
 (0)