Skip to content

Commit 5110862

Browse files
committed
Add Cookie and HttpHeaders stubs
1 parent 9db13ff commit 5110862

File tree

2 files changed

+355
-0
lines changed

2 files changed

+355
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
<?php
2+
3+
namespace Bitrix\Main\Web;
4+
5+
/**
6+
* Cookie - класс для работы с файлами cookie.
7+
8+
* Аналоги в старом ядре:
9+
* CMain::set_cookie - для создания,
10+
* CMain::get_cookie - для получения.
11+
*
12+
* В ядре D7 cookie задавать нужно через класс Bitrix\Main\HttpResponse, получать их нужно через класс Bitrix\Main\HttpRequest.
13+
* @link https://dev.1c-bitrix.ru/api_d7/bitrix/main/web/cookie/index.php
14+
*/
15+
class Cookie
16+
{
17+
const SPREAD_SITES = 1;
18+
const SPREAD_DOMAIN = 2;
19+
20+
/**
21+
* Cookie constructor.
22+
*
23+
* @param string $name The cooke name
24+
* @param string|null $value The cooke value
25+
* @param integer $expires Timestamp
26+
* @param boolean $addPrefix Name prefix, usually BITRIX_SM_
27+
* @return void
28+
*/
29+
public function __construct(
30+
string $name,
31+
?string $value,
32+
?int $expires = null,
33+
bool $addPrefix = true
34+
): void { }
35+
36+
/**
37+
* Undocumented function
38+
*
39+
* @param string $domain
40+
* @return $this
41+
*/
42+
public function setDomain(string $domain): self
43+
{
44+
return $this;
45+
}
46+
47+
/**
48+
* Undocumented function
49+
*
50+
* @return string
51+
*/
52+
public function getDomain(): string
53+
{
54+
return '';
55+
}
56+
57+
/**
58+
* Undocumented function
59+
*
60+
* @param integer $expires
61+
* @return $this
62+
*/
63+
public function setExpires(int $expires): self
64+
{
65+
return $this;
66+
}
67+
68+
/**
69+
* Undocumented function
70+
*
71+
* @return integer
72+
*/
73+
public function getExpires(): int
74+
{
75+
return 0;
76+
}
77+
78+
/**
79+
* Undocumented function
80+
*
81+
* @param boolean $httpOnly
82+
* @return $this
83+
*/
84+
public function setHttpOnly(bool $httpOnly): self
85+
{
86+
return $this;
87+
}
88+
89+
/**
90+
* Undocumented function
91+
*
92+
* @return boolean
93+
*/
94+
public function getHttpOnly(): bool
95+
{
96+
return false;
97+
}
98+
99+
/**
100+
* Undocumented function
101+
*
102+
* @param string $name
103+
* @return $this
104+
*/
105+
public function setName(string $name): self
106+
{
107+
return $this;
108+
}
109+
110+
/**
111+
* Undocumented function
112+
*
113+
* @return string
114+
*/
115+
public function getName(): string
116+
{
117+
return '';
118+
}
119+
120+
/**
121+
* Undocumented function
122+
*
123+
* @param string $path
124+
* @return $this
125+
*/
126+
public function setPath(string $path): self
127+
{
128+
return $this;
129+
}
130+
131+
/**
132+
* Undocumented function
133+
*
134+
* @return string
135+
*/
136+
public function getPath(): string
137+
{
138+
return '';
139+
}
140+
141+
/**
142+
* Undocumented function
143+
*
144+
* @param boolean $secure
145+
* @return self
146+
*/
147+
public function setSecure(bool $secure): self
148+
{
149+
return $this;
150+
}
151+
152+
/**
153+
* Undocumented function
154+
*
155+
* @return boolean
156+
*/
157+
public function getSecure(): bool
158+
{
159+
return false;
160+
}
161+
162+
/**
163+
* Undocumented function
164+
*
165+
* @param string|null $value
166+
* @return self
167+
*/
168+
public function setValue(?string $value): self
169+
{
170+
return $this;
171+
}
172+
173+
/**
174+
* Undocumented function
175+
*
176+
* @return string|null
177+
*/
178+
public function getValue(): ?string
179+
{
180+
return '';
181+
}
182+
183+
/**
184+
* Undocumented function
185+
*
186+
* @param static::SPREAD_DOMAIN|static::SPREAD_SITES $spread
187+
* @return self
188+
*/
189+
public function setSpread(int $spread): self
190+
{
191+
return $this;
192+
}
193+
194+
/**
195+
* Undocumented function
196+
*
197+
* @return static::SPREAD_DOMAIN|static::SPREAD_SITES
198+
*/
199+
public function getSpread(): int
200+
{
201+
return static::SPREAD_SITES;
202+
}
203+
204+
/**
205+
* Returns the domain from the sites settings to use with cookies.
206+
*
207+
* @return string
208+
* @throws \Bitrix\Main\Db\SqlQueryException
209+
* @throws \Bitrix\Main\SystemException
210+
*/
211+
public static function getCookieDomain()
212+
{
213+
return '';
214+
}
215+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<?php
2+
3+
namespace Bitrix\Main\Web;
4+
5+
use IteratorAggregate;
6+
use Traversable;
7+
8+
/**
9+
* HttpHeaders - класс для работы с заголовками.
10+
*
11+
* @link https://dev.1c-bitrix.ru/api_d7/bitrix/main/web/httpheaders/index.php
12+
*/
13+
class HttpHeaders implements IteratorAggregate
14+
{
15+
/**
16+
* Нестатический метод добавляет заголовок.
17+
*
18+
* @param string $name
19+
* @param string $value
20+
* @return void
21+
* @link https://dev.1c-bitrix.ru/api_d7/bitrix/main/web/httpheaders/add.php
22+
*/
23+
public function add(string $name, string $value): void
24+
{ }
25+
26+
private function refineString(string $string): string
27+
{
28+
return '';
29+
}
30+
31+
/**
32+
* Нестатический метод устанавливает значение заголовка.
33+
*
34+
* @param string $name
35+
* @param string|null $value
36+
* @return void
37+
* @link https://dev.1c-bitrix.ru/api_d7/bitrix/main/web/httpheaders/set.php
38+
*/
39+
public function set($name, $value): void
40+
{ }
41+
42+
/**
43+
* Нестатический метод возвращает заголовок по его имени.
44+
*
45+
* @param string $name Имя заголовка.
46+
* @param boolean $returnArray Если true, то возвращает массив с несколькими значениями.
47+
* @return string|null|array
48+
* @link https://dev.1c-bitrix.ru/api_d7/bitrix/main/web/httpheaders/get.php
49+
*/
50+
public function get(string $name, bool $returnArray = false)
51+
{ }
52+
53+
/**
54+
* Deletes a header or headers by its name.
55+
*
56+
* @param string $name
57+
* @return void
58+
*/
59+
public function delete(string $name): void
60+
{ }
61+
62+
/**
63+
* Нестатический метод очищает все заголовки.
64+
*
65+
* @return void
66+
* @link Нестатический метод очищает все заголовки.
67+
*/
68+
public function clear(): void
69+
{ }
70+
71+
/**
72+
* Нестатический метод возвращает строковое представление запроса HTTP.
73+
*
74+
* @return string
75+
* @link https://dev.1c-bitrix.ru/api_d7/bitrix/main/web/httpheaders/tostring.php
76+
*/
77+
public function toString(): string
78+
{
79+
return '';
80+
}
81+
82+
/**
83+
* Нестатический метод возвращает заголовки в виде исходного массива.
84+
*
85+
* @return array
86+
* @link https://dev.1c-bitrix.ru/api_d7/bitrix/main/web/httpheaders/toarray.php
87+
*/
88+
public function toArray()
89+
{
90+
return [];
91+
}
92+
93+
/**
94+
* Нестатический метод возвращает тип контента из Content-Type заголовка.
95+
*
96+
* @return string|null
97+
* @link https://dev.1c-bitrix.ru/api_d7/bitrix/main/web/httpheaders/getcontenttype.php
98+
*/
99+
public function getContentType(): ?string
100+
{ }
101+
102+
/**
103+
* Нестатический метод возвращает кодировку из Content-Type заголовка.
104+
*
105+
* @return string|null
106+
* @link https://dev.1c-bitrix.ru/api_d7/bitrix/main/web/httpheaders/getcharset.php
107+
*/
108+
public function getCharset(): ?string
109+
{ }
110+
111+
/**
112+
* Нестатический метод возвращает disposition-type из Content-Disposition заголовка.
113+
*
114+
* @return string|null Disposition-type part of the Content-Disposition header if found or null otherwise.
115+
* @link https://dev.1c-bitrix.ru/api_d7/bitrix/main/web/httpheaders/getcontentdisposition.php
116+
*/
117+
public function getContentDisposition(): ?string
118+
{ }
119+
120+
/**
121+
* Нестатический метод возвращает имя файла из Content-disposition заголовка.
122+
*
123+
* @return string|null Filename if it was found in the Content-disposition header or null otherwise.
124+
* @link https://dev.1c-bitrix.ru/api_d7/bitrix/main/web/httpheaders/getfilename.php
125+
*/
126+
public function getFilename(): ?string
127+
{ }
128+
129+
/**
130+
* Retrieve an external iterator
131+
* @link https://php.net/manual/en/iteratoraggregate.getiterator.php
132+
* @return Traversable An instance of an object implementing <b>Iterator</b> or
133+
* <b>Traversable</b>
134+
* @since 5.0.0
135+
*/
136+
public function getIterator(): \ArrayIterator
137+
{
138+
return new \ArrayIterator([]);
139+
}
140+
}

0 commit comments

Comments
 (0)