Stop forward declaring global QueryOptimiser in API header
[xapian.git] / xapian-bindings / php / add-php-type-hints
blob796f66e732d4daff87ea3e7640a54fb68a575339
1 #!/usr/bin/perl -w
2 # Add PHP type hints for classes.
4 # Copyright (C) 2011,2012,2017 Olly Betts
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to
8 # deal in the Software without restriction, including without limitation the
9 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 # sell copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 # IN THE SOFTWARE.
24 use strict;
26 my $current_class;
28 while (<>) {
29 if (/^(?:abstract )?class (\w+)/) {
30 $current_class = $1;
31 print;
32 next;
35 if (s/(function equals\()(\$o\))/$1$current_class $2/) {
36 # OK!
37 } elsif (s/(function unserialise\(.*)(\$registry\b)/$1XapianRegistry $2/) {
38 # OK!
39 } elsif (s/(function set_stemmer\()(\$stem)/$1XapianStem $2/) {
40 # OK!
41 } elsif (s/(function set_stopper\()(\$stop)/$1XapianStopper $2/) {
42 # OK!
43 } elsif (s/(function (?:set|add)_document\()(\$doc)/$1XapianDocument $2/) {
44 # OK!
45 } elsif (s/(function replace_document\(.*)(\$doc)/$1XapianDocument $2/) {
46 # OK!
47 } elsif (s/(function (?:set|add)_database\()(\$d)/$1XapianDatabase $2/) {
48 # OK!
49 # This would break existing subclasses as the signature must match.
50 # } elsif (s/(function apply\()(\$doc)/$1XapianDocument $2/) {
51 # # OK!
52 } elsif (s/(function set_query\()(\$query\b)/$1XapianQuery $2/) {
53 # OK!
54 } elsif (s/(function add_matchspy\()(\$spy\b)/$1XapianMatchSpy $2/) {
55 # OK!
56 } elsif (s/(function set_weighting_scheme\()(\$weight)/$1XapianWeight $2/) {
57 # OK!
58 } elsif (s/(function set_sort\w+\()(\$sorter\b)/$1XapianKeyMaker $2/) {
59 # OK!
60 } elsif (s/(function get_mset\(.*)(\$mdecider\b)/$1XapianMatchDecider $2/) {
61 # OK!
62 } elsif (s/(function get_eset\(.*)(\$edecider\b)/$1XapianExpandDecider $2/) {
63 s/(function get_eset\(.*)(\$(?:om)?rset\b)/$1XapianRSet $2/;
64 # OK!
65 } elsif (s/(function add_rangeprocessor\()(\$r)/$1XapianRangeProcessor $2/) {
66 # OK!
67 } elsif (s/(function add_valuerangeprocessor\()(\$v)/$1XapianValueRangeProcessor $2/) {
68 # OK!
69 } elsif (s/(function register_weighting_scheme\()(\$w)/$1XapianWeight $2/) {
70 # OK!
71 } elsif (s/(function register_posting_source\()(\$)/$1XapianPostingSource $2/) {
72 # OK!
73 } elsif (s/(function register_match_spy\()(\$)/$1XapianMatchSpy $2/) {
74 # OK!
75 } elsif (s/(function init\()(\$d(?:b|atabase))/$1XapianDatabase $2/) {
76 # OK!
78 print;