dropbox-sign 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +26 -9
  4. data/VERSION +1 -0
  5. data/bin/release +39 -0
  6. data/bin/ruby +1 -0
  7. data/docs/BulkSendJobApi.md +5 -3
  8. data/docs/SignatureRequestApi.md +3 -3
  9. data/docs/SignatureRequestCreateEmbeddedRequest.md +1 -1
  10. data/docs/SignatureRequestSendRequest.md +1 -1
  11. data/docs/SubFormFieldsPerDocumentBase.md +1 -1
  12. data/docs/TeamResponse.md +1 -0
  13. data/docs/TemplateCreateEmbeddedDraftRequest.md +1 -1
  14. data/docs/TemplateResponse.md +2 -2
  15. data/docs/TemplateResponseDocument.md +3 -3
  16. data/docs/{TemplateResponseCustomField.md → TemplateResponseDocumentCustomFieldBase.md} +6 -8
  17. data/docs/TemplateResponseDocumentCustomFieldCheckbox.md +10 -0
  18. data/docs/TemplateResponseDocumentCustomFieldText.md +14 -0
  19. data/docs/TemplateResponseDocumentFieldGroup.md +1 -1
  20. data/docs/TemplateResponseDocumentFieldGroupRule.md +11 -0
  21. data/docs/{TemplateResponseDocumentFormField.md → TemplateResponseDocumentFormFieldBase.md} +5 -8
  22. data/docs/TemplateResponseDocumentFormFieldCheckbox.md +10 -0
  23. data/docs/TemplateResponseDocumentFormFieldDateSigned.md +10 -0
  24. data/docs/TemplateResponseDocumentFormFieldDropdown.md +10 -0
  25. data/docs/TemplateResponseDocumentFormFieldHyperlink.md +14 -0
  26. data/docs/TemplateResponseDocumentFormFieldInitials.md +10 -0
  27. data/docs/TemplateResponseDocumentFormFieldRadio.md +10 -0
  28. data/docs/TemplateResponseDocumentFormFieldSignature.md +10 -0
  29. data/docs/TemplateResponseDocumentFormFieldText.md +15 -0
  30. data/docs/{TemplateResponseDocumentStaticField.md → TemplateResponseDocumentStaticFieldBase.md} +6 -5
  31. data/docs/TemplateResponseDocumentStaticFieldCheckbox.md +10 -0
  32. data/docs/TemplateResponseDocumentStaticFieldDateSigned.md +10 -0
  33. data/docs/TemplateResponseDocumentStaticFieldDropdown.md +10 -0
  34. data/docs/TemplateResponseDocumentStaticFieldHyperlink.md +10 -0
  35. data/docs/TemplateResponseDocumentStaticFieldInitials.md +10 -0
  36. data/docs/TemplateResponseDocumentStaticFieldRadio.md +10 -0
  37. data/docs/TemplateResponseDocumentStaticFieldSignature.md +10 -0
  38. data/docs/TemplateResponseDocumentStaticFieldText.md +10 -0
  39. data/docs/TemplateResponseFieldAvgTextLength.md +1 -1
  40. data/docs/UnclaimedDraftApi.md +2 -2
  41. data/docs/UnclaimedDraftCreateEmbeddedRequest.md +1 -1
  42. data/docs/UnclaimedDraftCreateRequest.md +1 -1
  43. data/examples/SignatureRequestCreateEmbedded.rb +1 -1
  44. data/examples/SignatureRequestSend.rb +2 -2
  45. data/examples/UnclaimedDraftCreate.rb +2 -2
  46. data/lib/dropbox-sign/api/bulk_send_job_api.rb +6 -0
  47. data/lib/dropbox-sign/models/signature_request_create_embedded_request.rb +1 -1
  48. data/lib/dropbox-sign/models/signature_request_send_request.rb +1 -1
  49. data/lib/dropbox-sign/models/sub_form_fields_per_document_base.rb +1 -1
  50. data/lib/dropbox-sign/models/team_response.rb +17 -4
  51. data/lib/dropbox-sign/models/template_create_embedded_draft_request.rb +1 -1
  52. data/lib/dropbox-sign/models/template_response.rb +5 -5
  53. data/lib/dropbox-sign/models/template_response_document.rb +9 -9
  54. data/lib/dropbox-sign/models/{template_response_document_static_field.rb → template_response_document_custom_field_base.rb} +75 -43
  55. data/lib/dropbox-sign/models/template_response_document_custom_field_checkbox.rb +263 -0
  56. data/lib/dropbox-sign/models/template_response_document_custom_field_text.rb +306 -0
  57. data/lib/dropbox-sign/models/template_response_document_field_group.rb +2 -3
  58. data/lib/dropbox-sign/models/template_response_document_field_group_rule.rb +263 -0
  59. data/lib/dropbox-sign/models/{template_response_named_form_field.rb → template_response_document_form_field_base.rb} +82 -79
  60. data/lib/dropbox-sign/models/template_response_document_form_field_checkbox.rb +263 -0
  61. data/lib/dropbox-sign/models/template_response_document_form_field_date_signed.rb +263 -0
  62. data/lib/dropbox-sign/models/template_response_document_form_field_dropdown.rb +263 -0
  63. data/lib/dropbox-sign/models/template_response_document_form_field_hyperlink.rb +306 -0
  64. data/lib/dropbox-sign/models/template_response_document_form_field_initials.rb +263 -0
  65. data/lib/dropbox-sign/models/template_response_document_form_field_radio.rb +263 -0
  66. data/lib/dropbox-sign/models/template_response_document_form_field_signature.rb +263 -0
  67. data/lib/dropbox-sign/models/{template_response_document_form_field.rb → template_response_document_form_field_text.rb} +53 -132
  68. data/lib/dropbox-sign/models/{template_response_custom_field.rb → template_response_document_static_field_base.rb} +94 -112
  69. data/lib/dropbox-sign/models/template_response_document_static_field_checkbox.rb +263 -0
  70. data/lib/dropbox-sign/models/template_response_document_static_field_date_signed.rb +263 -0
  71. data/lib/dropbox-sign/models/template_response_document_static_field_dropdown.rb +263 -0
  72. data/lib/dropbox-sign/models/template_response_document_static_field_hyperlink.rb +263 -0
  73. data/lib/dropbox-sign/models/template_response_document_static_field_initials.rb +263 -0
  74. data/lib/dropbox-sign/models/template_response_document_static_field_radio.rb +263 -0
  75. data/lib/dropbox-sign/models/template_response_document_static_field_signature.rb +263 -0
  76. data/lib/dropbox-sign/models/template_response_document_static_field_text.rb +263 -0
  77. data/lib/dropbox-sign/models/template_response_field_avg_text_length.rb +1 -1
  78. data/lib/dropbox-sign/models/unclaimed_draft_create_embedded_request.rb +1 -1
  79. data/lib/dropbox-sign/models/unclaimed_draft_create_request.rb +1 -1
  80. data/lib/dropbox-sign/version.rb +1 -1
  81. data/lib/dropbox-sign.rb +22 -5
  82. data/openapi-config.yaml +4 -1
  83. data/openapi-sdk.yaml +598 -186
  84. data/templates/VERSION-root.mustache +1 -0
  85. data/test_fixtures/AccountCreateResponse.json +1 -0
  86. data/test_fixtures/ApiAppGetResponse.json +1 -0
  87. data/test_fixtures/ApiAppListResponse.json +1 -0
  88. data/test_fixtures/BulkSendJobGetResponse.json +8 -3
  89. data/test_fixtures/SignatureRequestGetResponse.json +65 -65
  90. data/test_fixtures/SignatureRequestListResponse.json +11 -4
  91. data/test_fixtures/TemplateGetResponse.json +1064 -41
  92. data/test_fixtures/TemplateListResponse.json +513 -44
  93. metadata +58 -64
  94. data/docs/TemplateResponseDocumentCustomField.md +0 -25
  95. data/docs/TemplateResponseNamedFormField.md +0 -23
  96. data/lib/dropbox-sign/models/template_response_document_custom_field.rb +0 -454
  97. data/vendor/autoload.php +0 -7
  98. data/vendor/bin/yaml-lint +0 -117
  99. data/vendor/composer/ClassLoader.php +0 -572
  100. data/vendor/composer/InstalledVersions.php +0 -350
  101. data/vendor/composer/LICENSE +0 -21
  102. data/vendor/composer/autoload_classmap.php +0 -10
  103. data/vendor/composer/autoload_files.php +0 -11
  104. data/vendor/composer/autoload_namespaces.php +0 -9
  105. data/vendor/composer/autoload_psr4.php +0 -11
  106. data/vendor/composer/autoload_real.php +0 -80
  107. data/vendor/composer/autoload_static.php +0 -46
  108. data/vendor/composer/installed.json +0 -239
  109. data/vendor/composer/installed.php +0 -50
  110. data/vendor/composer/platform_check.php +0 -26
  111. data/vendor/symfony/deprecation-contracts/.gitignore +0 -3
  112. data/vendor/symfony/deprecation-contracts/CHANGELOG.md +0 -5
  113. data/vendor/symfony/deprecation-contracts/LICENSE +0 -19
  114. data/vendor/symfony/deprecation-contracts/README.md +0 -26
  115. data/vendor/symfony/deprecation-contracts/composer.json +0 -35
  116. data/vendor/symfony/deprecation-contracts/function.php +0 -27
  117. data/vendor/symfony/polyfill-ctype/Ctype.php +0 -232
  118. data/vendor/symfony/polyfill-ctype/LICENSE +0 -19
  119. data/vendor/symfony/polyfill-ctype/README.md +0 -12
  120. data/vendor/symfony/polyfill-ctype/bootstrap.php +0 -50
  121. data/vendor/symfony/polyfill-ctype/bootstrap80.php +0 -46
  122. data/vendor/symfony/polyfill-ctype/composer.json +0 -41
  123. data/vendor/symfony/yaml/CHANGELOG.md +0 -237
  124. data/vendor/symfony/yaml/Command/LintCommand.php +0 -289
  125. data/vendor/symfony/yaml/Dumper.php +0 -140
  126. data/vendor/symfony/yaml/Escaper.php +0 -95
  127. data/vendor/symfony/yaml/Exception/DumpException.php +0 -21
  128. data/vendor/symfony/yaml/Exception/ExceptionInterface.php +0 -21
  129. data/vendor/symfony/yaml/Exception/ParseException.php +0 -132
  130. data/vendor/symfony/yaml/Exception/RuntimeException.php +0 -21
  131. data/vendor/symfony/yaml/Inline.php +0 -812
  132. data/vendor/symfony/yaml/LICENSE +0 -19
  133. data/vendor/symfony/yaml/Parser.php +0 -1305
  134. data/vendor/symfony/yaml/README.md +0 -13
  135. data/vendor/symfony/yaml/Resources/bin/yaml-lint +0 -45
  136. data/vendor/symfony/yaml/Tag/TaggedValue.php +0 -38
  137. data/vendor/symfony/yaml/Unescaper.php +0 -132
  138. data/vendor/symfony/yaml/Yaml.php +0 -100
  139. data/vendor/symfony/yaml/composer.json +0 -42
data/vendor/autoload.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- // autoload.php @generated by Composer
4
-
5
- require_once __DIR__ . '/composer/autoload_real.php';
6
-
7
- return ComposerAutoloaderInit0deac9bd9dfee5fa1b983a774a13067a::getLoader();
data/vendor/bin/yaml-lint DELETED
@@ -1,117 +0,0 @@
1
- #!/usr/bin/env php
2
- <?php
3
-
4
- /**
5
- * Proxy PHP file generated by Composer
6
- *
7
- * This file includes the referenced bin path (../symfony/yaml/Resources/bin/yaml-lint)
8
- * using a stream wrapper to prevent the shebang from being output on PHP<8
9
- *
10
- * @generated
11
- */
12
-
13
- namespace Composer;
14
-
15
- $GLOBALS['_composer_bin_dir'] = __DIR__;
16
- $GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php';
17
-
18
- if (PHP_VERSION_ID < 80000) {
19
- if (!class_exists('Composer\BinProxyWrapper')) {
20
- /**
21
- * @internal
22
- */
23
- final class BinProxyWrapper
24
- {
25
- private $handle;
26
- private $position;
27
- private $realpath;
28
-
29
- public function stream_open($path, $mode, $options, &$opened_path)
30
- {
31
- // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
32
- $opened_path = substr($path, 17);
33
- $this->realpath = realpath($opened_path) ?: $opened_path;
34
- $opened_path = $this->realpath;
35
- $this->handle = fopen($this->realpath, $mode);
36
- $this->position = 0;
37
-
38
- return (bool) $this->handle;
39
- }
40
-
41
- public function stream_read($count)
42
- {
43
- $data = fread($this->handle, $count);
44
-
45
- if ($this->position === 0) {
46
- $data = preg_replace('{^#!.*\r?\n}', '', $data);
47
- }
48
-
49
- $this->position += strlen($data);
50
-
51
- return $data;
52
- }
53
-
54
- public function stream_cast($castAs)
55
- {
56
- return $this->handle;
57
- }
58
-
59
- public function stream_close()
60
- {
61
- fclose($this->handle);
62
- }
63
-
64
- public function stream_lock($operation)
65
- {
66
- return $operation ? flock($this->handle, $operation) : true;
67
- }
68
-
69
- public function stream_seek($offset, $whence)
70
- {
71
- if (0 === fseek($this->handle, $offset, $whence)) {
72
- $this->position = ftell($this->handle);
73
- return true;
74
- }
75
-
76
- return false;
77
- }
78
-
79
- public function stream_tell()
80
- {
81
- return $this->position;
82
- }
83
-
84
- public function stream_eof()
85
- {
86
- return feof($this->handle);
87
- }
88
-
89
- public function stream_stat()
90
- {
91
- return array();
92
- }
93
-
94
- public function stream_set_option($option, $arg1, $arg2)
95
- {
96
- return true;
97
- }
98
-
99
- public function url_stat($path, $flags)
100
- {
101
- $path = substr($path, 17);
102
- if (file_exists($path)) {
103
- return stat($path);
104
- }
105
-
106
- return false;
107
- }
108
- }
109
- }
110
-
111
- if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) {
112
- include("phpvfscomposer://" . __DIR__ . '/..'.'/symfony/yaml/Resources/bin/yaml-lint');
113
- exit(0);
114
- }
115
- }
116
-
117
- include __DIR__ . '/..'.'/symfony/yaml/Resources/bin/yaml-lint';
@@ -1,572 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of Composer.
5
- *
6
- * (c) Nils Adermann <naderman@naderman.de>
7
- * Jordi Boggiano <j.boggiano@seld.be>
8
- *
9
- * For the full copyright and license information, please view the LICENSE
10
- * file that was distributed with this source code.
11
- */
12
-
13
- namespace Composer\Autoload;
14
-
15
- /**
16
- * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
- *
18
- * $loader = new \Composer\Autoload\ClassLoader();
19
- *
20
- * // register classes with namespaces
21
- * $loader->add('Symfony\Component', __DIR__.'/component');
22
- * $loader->add('Symfony', __DIR__.'/framework');
23
- *
24
- * // activate the autoloader
25
- * $loader->register();
26
- *
27
- * // to enable searching the include path (eg. for PEAR packages)
28
- * $loader->setUseIncludePath(true);
29
- *
30
- * In this example, if you try to use a class in the Symfony\Component
31
- * namespace or one of its children (Symfony\Component\Console for instance),
32
- * the autoloader will first look for the class under the component/
33
- * directory, and it will then fallback to the framework/ directory if not
34
- * found before giving up.
35
- *
36
- * This class is loosely based on the Symfony UniversalClassLoader.
37
- *
38
- * @author Fabien Potencier <fabien@symfony.com>
39
- * @author Jordi Boggiano <j.boggiano@seld.be>
40
- * @see https://www.php-fig.org/psr/psr-0/
41
- * @see https://www.php-fig.org/psr/psr-4/
42
- */
43
- class ClassLoader
44
- {
45
- /** @var ?string */
46
- private $vendorDir;
47
-
48
- // PSR-4
49
- /**
50
- * @var array[]
51
- * @psalm-var array<string, array<string, int>>
52
- */
53
- private $prefixLengthsPsr4 = array();
54
- /**
55
- * @var array[]
56
- * @psalm-var array<string, array<int, string>>
57
- */
58
- private $prefixDirsPsr4 = array();
59
- /**
60
- * @var array[]
61
- * @psalm-var array<string, string>
62
- */
63
- private $fallbackDirsPsr4 = array();
64
-
65
- // PSR-0
66
- /**
67
- * @var array[]
68
- * @psalm-var array<string, array<string, string[]>>
69
- */
70
- private $prefixesPsr0 = array();
71
- /**
72
- * @var array[]
73
- * @psalm-var array<string, string>
74
- */
75
- private $fallbackDirsPsr0 = array();
76
-
77
- /** @var bool */
78
- private $useIncludePath = false;
79
-
80
- /**
81
- * @var string[]
82
- * @psalm-var array<string, string>
83
- */
84
- private $classMap = array();
85
-
86
- /** @var bool */
87
- private $classMapAuthoritative = false;
88
-
89
- /**
90
- * @var bool[]
91
- * @psalm-var array<string, bool>
92
- */
93
- private $missingClasses = array();
94
-
95
- /** @var ?string */
96
- private $apcuPrefix;
97
-
98
- /**
99
- * @var self[]
100
- */
101
- private static $registeredLoaders = array();
102
-
103
- /**
104
- * @param ?string $vendorDir
105
- */
106
- public function __construct($vendorDir = null)
107
- {
108
- $this->vendorDir = $vendorDir;
109
- }
110
-
111
- /**
112
- * @return string[]
113
- */
114
- public function getPrefixes()
115
- {
116
- if (!empty($this->prefixesPsr0)) {
117
- return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
118
- }
119
-
120
- return array();
121
- }
122
-
123
- /**
124
- * @return array[]
125
- * @psalm-return array<string, array<int, string>>
126
- */
127
- public function getPrefixesPsr4()
128
- {
129
- return $this->prefixDirsPsr4;
130
- }
131
-
132
- /**
133
- * @return array[]
134
- * @psalm-return array<string, string>
135
- */
136
- public function getFallbackDirs()
137
- {
138
- return $this->fallbackDirsPsr0;
139
- }
140
-
141
- /**
142
- * @return array[]
143
- * @psalm-return array<string, string>
144
- */
145
- public function getFallbackDirsPsr4()
146
- {
147
- return $this->fallbackDirsPsr4;
148
- }
149
-
150
- /**
151
- * @return string[] Array of classname => path
152
- * @psalm-return array<string, string>
153
- */
154
- public function getClassMap()
155
- {
156
- return $this->classMap;
157
- }
158
-
159
- /**
160
- * @param string[] $classMap Class to filename map
161
- * @psalm-param array<string, string> $classMap
162
- *
163
- * @return void
164
- */
165
- public function addClassMap(array $classMap)
166
- {
167
- if ($this->classMap) {
168
- $this->classMap = array_merge($this->classMap, $classMap);
169
- } else {
170
- $this->classMap = $classMap;
171
- }
172
- }
173
-
174
- /**
175
- * Registers a set of PSR-0 directories for a given prefix, either
176
- * appending or prepending to the ones previously set for this prefix.
177
- *
178
- * @param string $prefix The prefix
179
- * @param string[]|string $paths The PSR-0 root directories
180
- * @param bool $prepend Whether to prepend the directories
181
- *
182
- * @return void
183
- */
184
- public function add($prefix, $paths, $prepend = false)
185
- {
186
- if (!$prefix) {
187
- if ($prepend) {
188
- $this->fallbackDirsPsr0 = array_merge(
189
- (array) $paths,
190
- $this->fallbackDirsPsr0
191
- );
192
- } else {
193
- $this->fallbackDirsPsr0 = array_merge(
194
- $this->fallbackDirsPsr0,
195
- (array) $paths
196
- );
197
- }
198
-
199
- return;
200
- }
201
-
202
- $first = $prefix[0];
203
- if (!isset($this->prefixesPsr0[$first][$prefix])) {
204
- $this->prefixesPsr0[$first][$prefix] = (array) $paths;
205
-
206
- return;
207
- }
208
- if ($prepend) {
209
- $this->prefixesPsr0[$first][$prefix] = array_merge(
210
- (array) $paths,
211
- $this->prefixesPsr0[$first][$prefix]
212
- );
213
- } else {
214
- $this->prefixesPsr0[$first][$prefix] = array_merge(
215
- $this->prefixesPsr0[$first][$prefix],
216
- (array) $paths
217
- );
218
- }
219
- }
220
-
221
- /**
222
- * Registers a set of PSR-4 directories for a given namespace, either
223
- * appending or prepending to the ones previously set for this namespace.
224
- *
225
- * @param string $prefix The prefix/namespace, with trailing '\\'
226
- * @param string[]|string $paths The PSR-4 base directories
227
- * @param bool $prepend Whether to prepend the directories
228
- *
229
- * @throws \InvalidArgumentException
230
- *
231
- * @return void
232
- */
233
- public function addPsr4($prefix, $paths, $prepend = false)
234
- {
235
- if (!$prefix) {
236
- // Register directories for the root namespace.
237
- if ($prepend) {
238
- $this->fallbackDirsPsr4 = array_merge(
239
- (array) $paths,
240
- $this->fallbackDirsPsr4
241
- );
242
- } else {
243
- $this->fallbackDirsPsr4 = array_merge(
244
- $this->fallbackDirsPsr4,
245
- (array) $paths
246
- );
247
- }
248
- } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
249
- // Register directories for a new namespace.
250
- $length = strlen($prefix);
251
- if ('\\' !== $prefix[$length - 1]) {
252
- throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
253
- }
254
- $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
255
- $this->prefixDirsPsr4[$prefix] = (array) $paths;
256
- } elseif ($prepend) {
257
- // Prepend directories for an already registered namespace.
258
- $this->prefixDirsPsr4[$prefix] = array_merge(
259
- (array) $paths,
260
- $this->prefixDirsPsr4[$prefix]
261
- );
262
- } else {
263
- // Append directories for an already registered namespace.
264
- $this->prefixDirsPsr4[$prefix] = array_merge(
265
- $this->prefixDirsPsr4[$prefix],
266
- (array) $paths
267
- );
268
- }
269
- }
270
-
271
- /**
272
- * Registers a set of PSR-0 directories for a given prefix,
273
- * replacing any others previously set for this prefix.
274
- *
275
- * @param string $prefix The prefix
276
- * @param string[]|string $paths The PSR-0 base directories
277
- *
278
- * @return void
279
- */
280
- public function set($prefix, $paths)
281
- {
282
- if (!$prefix) {
283
- $this->fallbackDirsPsr0 = (array) $paths;
284
- } else {
285
- $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
286
- }
287
- }
288
-
289
- /**
290
- * Registers a set of PSR-4 directories for a given namespace,
291
- * replacing any others previously set for this namespace.
292
- *
293
- * @param string $prefix The prefix/namespace, with trailing '\\'
294
- * @param string[]|string $paths The PSR-4 base directories
295
- *
296
- * @throws \InvalidArgumentException
297
- *
298
- * @return void
299
- */
300
- public function setPsr4($prefix, $paths)
301
- {
302
- if (!$prefix) {
303
- $this->fallbackDirsPsr4 = (array) $paths;
304
- } else {
305
- $length = strlen($prefix);
306
- if ('\\' !== $prefix[$length - 1]) {
307
- throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
308
- }
309
- $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
310
- $this->prefixDirsPsr4[$prefix] = (array) $paths;
311
- }
312
- }
313
-
314
- /**
315
- * Turns on searching the include path for class files.
316
- *
317
- * @param bool $useIncludePath
318
- *
319
- * @return void
320
- */
321
- public function setUseIncludePath($useIncludePath)
322
- {
323
- $this->useIncludePath = $useIncludePath;
324
- }
325
-
326
- /**
327
- * Can be used to check if the autoloader uses the include path to check
328
- * for classes.
329
- *
330
- * @return bool
331
- */
332
- public function getUseIncludePath()
333
- {
334
- return $this->useIncludePath;
335
- }
336
-
337
- /**
338
- * Turns off searching the prefix and fallback directories for classes
339
- * that have not been registered with the class map.
340
- *
341
- * @param bool $classMapAuthoritative
342
- *
343
- * @return void
344
- */
345
- public function setClassMapAuthoritative($classMapAuthoritative)
346
- {
347
- $this->classMapAuthoritative = $classMapAuthoritative;
348
- }
349
-
350
- /**
351
- * Should class lookup fail if not found in the current class map?
352
- *
353
- * @return bool
354
- */
355
- public function isClassMapAuthoritative()
356
- {
357
- return $this->classMapAuthoritative;
358
- }
359
-
360
- /**
361
- * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
362
- *
363
- * @param string|null $apcuPrefix
364
- *
365
- * @return void
366
- */
367
- public function setApcuPrefix($apcuPrefix)
368
- {
369
- $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
370
- }
371
-
372
- /**
373
- * The APCu prefix in use, or null if APCu caching is not enabled.
374
- *
375
- * @return string|null
376
- */
377
- public function getApcuPrefix()
378
- {
379
- return $this->apcuPrefix;
380
- }
381
-
382
- /**
383
- * Registers this instance as an autoloader.
384
- *
385
- * @param bool $prepend Whether to prepend the autoloader or not
386
- *
387
- * @return void
388
- */
389
- public function register($prepend = false)
390
- {
391
- spl_autoload_register(array($this, 'loadClass'), true, $prepend);
392
-
393
- if (null === $this->vendorDir) {
394
- return;
395
- }
396
-
397
- if ($prepend) {
398
- self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
399
- } else {
400
- unset(self::$registeredLoaders[$this->vendorDir]);
401
- self::$registeredLoaders[$this->vendorDir] = $this;
402
- }
403
- }
404
-
405
- /**
406
- * Unregisters this instance as an autoloader.
407
- *
408
- * @return void
409
- */
410
- public function unregister()
411
- {
412
- spl_autoload_unregister(array($this, 'loadClass'));
413
-
414
- if (null !== $this->vendorDir) {
415
- unset(self::$registeredLoaders[$this->vendorDir]);
416
- }
417
- }
418
-
419
- /**
420
- * Loads the given class or interface.
421
- *
422
- * @param string $class The name of the class
423
- * @return true|null True if loaded, null otherwise
424
- */
425
- public function loadClass($class)
426
- {
427
- if ($file = $this->findFile($class)) {
428
- includeFile($file);
429
-
430
- return true;
431
- }
432
-
433
- return null;
434
- }
435
-
436
- /**
437
- * Finds the path to the file where the class is defined.
438
- *
439
- * @param string $class The name of the class
440
- *
441
- * @return string|false The path if found, false otherwise
442
- */
443
- public function findFile($class)
444
- {
445
- // class map lookup
446
- if (isset($this->classMap[$class])) {
447
- return $this->classMap[$class];
448
- }
449
- if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
450
- return false;
451
- }
452
- if (null !== $this->apcuPrefix) {
453
- $file = apcu_fetch($this->apcuPrefix.$class, $hit);
454
- if ($hit) {
455
- return $file;
456
- }
457
- }
458
-
459
- $file = $this->findFileWithExtension($class, '.php');
460
-
461
- // Search for Hack files if we are running on HHVM
462
- if (false === $file && defined('HHVM_VERSION')) {
463
- $file = $this->findFileWithExtension($class, '.hh');
464
- }
465
-
466
- if (null !== $this->apcuPrefix) {
467
- apcu_add($this->apcuPrefix.$class, $file);
468
- }
469
-
470
- if (false === $file) {
471
- // Remember that this class does not exist.
472
- $this->missingClasses[$class] = true;
473
- }
474
-
475
- return $file;
476
- }
477
-
478
- /**
479
- * Returns the currently registered loaders indexed by their corresponding vendor directories.
480
- *
481
- * @return self[]
482
- */
483
- public static function getRegisteredLoaders()
484
- {
485
- return self::$registeredLoaders;
486
- }
487
-
488
- /**
489
- * @param string $class
490
- * @param string $ext
491
- * @return string|false
492
- */
493
- private function findFileWithExtension($class, $ext)
494
- {
495
- // PSR-4 lookup
496
- $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
497
-
498
- $first = $class[0];
499
- if (isset($this->prefixLengthsPsr4[$first])) {
500
- $subPath = $class;
501
- while (false !== $lastPos = strrpos($subPath, '\\')) {
502
- $subPath = substr($subPath, 0, $lastPos);
503
- $search = $subPath . '\\';
504
- if (isset($this->prefixDirsPsr4[$search])) {
505
- $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
506
- foreach ($this->prefixDirsPsr4[$search] as $dir) {
507
- if (file_exists($file = $dir . $pathEnd)) {
508
- return $file;
509
- }
510
- }
511
- }
512
- }
513
- }
514
-
515
- // PSR-4 fallback dirs
516
- foreach ($this->fallbackDirsPsr4 as $dir) {
517
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
518
- return $file;
519
- }
520
- }
521
-
522
- // PSR-0 lookup
523
- if (false !== $pos = strrpos($class, '\\')) {
524
- // namespaced class name
525
- $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
526
- . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
527
- } else {
528
- // PEAR-like class name
529
- $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
530
- }
531
-
532
- if (isset($this->prefixesPsr0[$first])) {
533
- foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
534
- if (0 === strpos($class, $prefix)) {
535
- foreach ($dirs as $dir) {
536
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
537
- return $file;
538
- }
539
- }
540
- }
541
- }
542
- }
543
-
544
- // PSR-0 fallback dirs
545
- foreach ($this->fallbackDirsPsr0 as $dir) {
546
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
547
- return $file;
548
- }
549
- }
550
-
551
- // PSR-0 include paths.
552
- if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
553
- return $file;
554
- }
555
-
556
- return false;
557
- }
558
- }
559
-
560
- /**
561
- * Scope isolated include.
562
- *
563
- * Prevents access to $this/self from included files.
564
- *
565
- * @param string $file
566
- * @return void
567
- * @private
568
- */
569
- function includeFile($file)
570
- {
571
- include $file;
572
- }