@@ -5,49 +5,49 @@ |
||
5 | 5 | |
6 | 6 | class CreateGroup extends BaseCommand |
7 | 7 | { |
8 | - protected $group = 'Auth'; |
|
9 | - protected $name = 'auth:create_group'; |
|
10 | - protected $description = "Adds a new group to the database."; |
|
8 | + protected $group = 'Auth'; |
|
9 | + protected $name = 'auth:create_group'; |
|
10 | + protected $description = "Adds a new group to the database."; |
|
11 | 11 | |
12 | - protected $usage = "auth:create_group [name] [description]"; |
|
13 | - protected $arguments = [ |
|
14 | - 'name' => "The name of the new group to create", |
|
15 | - 'description' => "Optional description 'in quotes'", |
|
16 | - ]; |
|
12 | + protected $usage = "auth:create_group [name] [description]"; |
|
13 | + protected $arguments = [ |
|
14 | + 'name' => "The name of the new group to create", |
|
15 | + 'description' => "Optional description 'in quotes'", |
|
16 | + ]; |
|
17 | 17 | |
18 | - public function run(array $params = []) |
|
18 | + public function run(array $params = []) |
|
19 | 19 | { |
20 | - $auth = service('authorization'); |
|
21 | - |
|
22 | - // consume or prompt for group name |
|
23 | - $name = array_shift($params); |
|
24 | - if (empty($name)) |
|
25 | - { |
|
26 | - $name = CLI::prompt('Group name', null, 'required'); |
|
27 | - } |
|
28 | - |
|
29 | - // consume or prompt for description |
|
30 | - $description = array_shift($params); |
|
31 | - if (empty($description)) |
|
32 | - { |
|
33 | - $description = CLI::prompt('Description', ''); |
|
34 | - } |
|
35 | - |
|
36 | - try |
|
37 | - { |
|
38 | - if (! $auth->createGroup($name, $description)) |
|
39 | - { |
|
40 | - foreach ($auth->error() as $message) |
|
41 | - { |
|
42 | - CLI::write($message, 'red'); |
|
43 | - } |
|
44 | - } |
|
45 | - } |
|
46 | - catch (\Exception $e) |
|
47 | - { |
|
48 | - $this->showError($e); |
|
49 | - } |
|
50 | - |
|
51 | - $this->call('auth:list_groups'); |
|
52 | - } |
|
20 | + $auth = service('authorization'); |
|
21 | + |
|
22 | + // consume or prompt for group name |
|
23 | + $name = array_shift($params); |
|
24 | + if (empty($name)) |
|
25 | + { |
|
26 | + $name = CLI::prompt('Group name', null, 'required'); |
|
27 | + } |
|
28 | + |
|
29 | + // consume or prompt for description |
|
30 | + $description = array_shift($params); |
|
31 | + if (empty($description)) |
|
32 | + { |
|
33 | + $description = CLI::prompt('Description', ''); |
|
34 | + } |
|
35 | + |
|
36 | + try |
|
37 | + { |
|
38 | + if (! $auth->createGroup($name, $description)) |
|
39 | + { |
|
40 | + foreach ($auth->error() as $message) |
|
41 | + { |
|
42 | + CLI::write($message, 'red'); |
|
43 | + } |
|
44 | + } |
|
45 | + } |
|
46 | + catch (\Exception $e) |
|
47 | + { |
|
48 | + $this->showError($e); |
|
49 | + } |
|
50 | + |
|
51 | + $this->call('auth:list_groups'); |
|
52 | + } |
|
53 | 53 | } |
@@ -6,46 +6,46 @@ |
||
6 | 6 | |
7 | 7 | class ActivateUser extends BaseCommand |
8 | 8 | { |
9 | - protected $group = 'Auth'; |
|
10 | - protected $name = 'auth:activate_user'; |
|
11 | - protected $description = 'Activate Existing User.'; |
|
9 | + protected $group = 'Auth'; |
|
10 | + protected $name = 'auth:activate_user'; |
|
11 | + protected $description = 'Activate Existing User.'; |
|
12 | 12 | |
13 | - protected $usage = 'auth:activate_user [identity]'; |
|
14 | - protected $arguments = [ |
|
15 | - 'identity' => 'User identity.', |
|
16 | - ]; |
|
13 | + protected $usage = 'auth:activate_user [identity]'; |
|
14 | + protected $arguments = [ |
|
15 | + 'identity' => 'User identity.', |
|
16 | + ]; |
|
17 | 17 | |
18 | - public function run(array $params = []) |
|
19 | - { |
|
20 | - // Consume or prompt for password |
|
21 | - $identity = array_shift($params); |
|
18 | + public function run(array $params = []) |
|
19 | + { |
|
20 | + // Consume or prompt for password |
|
21 | + $identity = array_shift($params); |
|
22 | 22 | |
23 | - if (empty($identity)) |
|
24 | - { |
|
25 | - $identity = CLI::prompt('Identity', null, 'required'); |
|
26 | - } |
|
23 | + if (empty($identity)) |
|
24 | + { |
|
25 | + $identity = CLI::prompt('Identity', null, 'required'); |
|
26 | + } |
|
27 | 27 | |
28 | - $type = filter_var($identity, FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; |
|
28 | + $type = filter_var($identity, FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; |
|
29 | 29 | |
30 | - $userModel = new UserModel(); |
|
31 | - $user = $userModel->where($type, $identity)->first(); |
|
30 | + $userModel = new UserModel(); |
|
31 | + $user = $userModel->where($type, $identity)->first(); |
|
32 | 32 | |
33 | - if (! $user) |
|
34 | - { |
|
35 | - CLI::write('User with identity: '. $identity .' not found.', 'red'); |
|
36 | - } |
|
37 | - else |
|
38 | - { |
|
39 | - $user->active = 1; |
|
33 | + if (! $user) |
|
34 | + { |
|
35 | + CLI::write('User with identity: '. $identity .' not found.', 'red'); |
|
36 | + } |
|
37 | + else |
|
38 | + { |
|
39 | + $user->active = 1; |
|
40 | 40 | |
41 | - if ($userModel->save($user)) |
|
42 | - { |
|
43 | - CLI::write('Sucessfuly activated the user with identity: ' . $identity , 'green'); |
|
44 | - } |
|
45 | - else |
|
46 | - { |
|
47 | - CLI::write('Failed to activate the user with identity: ' . $identity , 'red'); |
|
48 | - } |
|
49 | - } |
|
50 | - } |
|
41 | + if ($userModel->save($user)) |
|
42 | + { |
|
43 | + CLI::write('Sucessfuly activated the user with identity: ' . $identity , 'green'); |
|
44 | + } |
|
45 | + else |
|
46 | + { |
|
47 | + CLI::write('Failed to activate the user with identity: ' . $identity , 'red'); |
|
48 | + } |
|
49 | + } |
|
50 | + } |
|
51 | 51 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | public function down() |
168 | 168 | { |
169 | - // drop constraints first to prevent errors |
|
169 | + // drop constraints first to prevent errors |
|
170 | 170 | if ($this->db->DBDriver != 'SQLite3') // @phpstan-ignore-line |
171 | 171 | { |
172 | 172 | $this->forge->dropForeignKey('auth_tokens', 'auth_tokens_user_id_foreign'); |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | $this->forge->dropForeignKey('auth_users_permissions', 'auth_users_permissions_permission_id_foreign'); |
179 | 179 | } |
180 | 180 | |
181 | - $this->forge->dropTable('users', true); |
|
182 | - $this->forge->dropTable('auth_logins', true); |
|
183 | - $this->forge->dropTable('auth_tokens', true); |
|
184 | - $this->forge->dropTable('auth_reset_attempts', true); |
|
181 | + $this->forge->dropTable('users', true); |
|
182 | + $this->forge->dropTable('auth_logins', true); |
|
183 | + $this->forge->dropTable('auth_tokens', true); |
|
184 | + $this->forge->dropTable('auth_reset_attempts', true); |
|
185 | 185 | $this->forge->dropTable('auth_activation_attempts', true); |
186 | - $this->forge->dropTable('auth_groups', true); |
|
187 | - $this->forge->dropTable('auth_permissions', true); |
|
188 | - $this->forge->dropTable('auth_groups_permissions', true); |
|
189 | - $this->forge->dropTable('auth_groups_users', true); |
|
190 | - $this->forge->dropTable('auth_users_permissions', true); |
|
186 | + $this->forge->dropTable('auth_groups', true); |
|
187 | + $this->forge->dropTable('auth_permissions', true); |
|
188 | + $this->forge->dropTable('auth_groups_permissions', true); |
|
189 | + $this->forge->dropTable('auth_groups_users', true); |
|
190 | + $this->forge->dropTable('auth_users_permissions', true); |
|
191 | 191 | } |
192 | 192 | } |
@@ -45,15 +45,15 @@ discard block |
||
45 | 45 | */ |
46 | 46 | protected $roles = []; |
47 | 47 | |
48 | - /** |
|
49 | - * Automatically hashes the password when set. |
|
50 | - * |
|
51 | - * @see https://paragonie.com/blog/2015/04/secure-authentication-php-with-long-term-persistence |
|
52 | - * |
|
53 | - * @param string $password |
|
54 | - */ |
|
55 | - public function setPassword(string $password) |
|
56 | - { |
|
48 | + /** |
|
49 | + * Automatically hashes the password when set. |
|
50 | + * |
|
51 | + * @see https://paragonie.com/blog/2015/04/secure-authentication-php-with-long-term-persistence |
|
52 | + * |
|
53 | + * @param string $password |
|
54 | + */ |
|
55 | + public function setPassword(string $password) |
|
56 | + { |
|
57 | 57 | $this->attributes['password_hash'] = Password::hash($password); |
58 | 58 | |
59 | 59 | /* |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $this->attributes['reset_hash'] = null; |
69 | 69 | $this->attributes['reset_at'] = null; |
70 | 70 | $this->attributes['reset_expires'] = null; |
71 | - } |
|
71 | + } |
|
72 | 72 | |
73 | 73 | /** |
74 | 74 | * Force a user to reset their password on next page refresh |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | * @return $this |
94 | 94 | * @throws \Exception |
95 | 95 | */ |
96 | - public function generateResetHash() |
|
97 | - { |
|
98 | - $this->attributes['reset_hash'] = bin2hex(random_bytes(16)); |
|
99 | - $this->attributes['reset_expires'] = date('Y-m-d H:i:s', time() + config('Auth')->resetTime); |
|
96 | + public function generateResetHash() |
|
97 | + { |
|
98 | + $this->attributes['reset_hash'] = bin2hex(random_bytes(16)); |
|
99 | + $this->attributes['reset_expires'] = date('Y-m-d H:i:s', time() + config('Auth')->resetTime); |
|
100 | 100 | |
101 | - return $this; |
|
102 | - } |
|
101 | + return $this; |
|
102 | + } |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Generates a secure random hash to use for account activation. |
@@ -107,12 +107,12 @@ discard block |
||
107 | 107 | * @return $this |
108 | 108 | * @throws \Exception |
109 | 109 | */ |
110 | - public function generateActivateHash() |
|
111 | - { |
|
112 | - $this->attributes['activate_hash'] = bin2hex(random_bytes(16)); |
|
110 | + public function generateActivateHash() |
|
111 | + { |
|
112 | + $this->attributes['activate_hash'] = bin2hex(random_bytes(16)); |
|
113 | 113 | |
114 | - return $this; |
|
115 | - } |
|
114 | + return $this; |
|
115 | + } |
|
116 | 116 | |
117 | 117 | /** |
118 | 118 | * Activate user. |
@@ -149,42 +149,42 @@ discard block |
||
149 | 149 | return isset($this->attributes['active']) && $this->attributes['active'] == true; |
150 | 150 | } |
151 | 151 | |
152 | - /** |
|
153 | - * Bans a user. |
|
154 | - * |
|
155 | - * @param string $reason |
|
156 | - * |
|
157 | - * @return $this |
|
158 | - */ |
|
159 | - public function ban(string $reason) |
|
160 | - { |
|
161 | - $this->attributes['status'] = 'banned'; |
|
162 | - $this->attributes['status_message'] = $reason; |
|
163 | - |
|
164 | - return $this; |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * Removes a ban from a user. |
|
169 | - * |
|
170 | - * @return $this |
|
171 | - */ |
|
172 | - public function unBan() |
|
173 | - { |
|
174 | - $this->attributes['status'] = $this->status_message = ''; |
|
175 | - |
|
176 | - return $this; |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * Checks to see if a user has been banned. |
|
181 | - * |
|
182 | - * @return bool |
|
183 | - */ |
|
184 | - public function isBanned(): bool |
|
185 | - { |
|
186 | - return isset($this->attributes['status']) && $this->attributes['status'] === 'banned'; |
|
187 | - } |
|
152 | + /** |
|
153 | + * Bans a user. |
|
154 | + * |
|
155 | + * @param string $reason |
|
156 | + * |
|
157 | + * @return $this |
|
158 | + */ |
|
159 | + public function ban(string $reason) |
|
160 | + { |
|
161 | + $this->attributes['status'] = 'banned'; |
|
162 | + $this->attributes['status_message'] = $reason; |
|
163 | + |
|
164 | + return $this; |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * Removes a ban from a user. |
|
169 | + * |
|
170 | + * @return $this |
|
171 | + */ |
|
172 | + public function unBan() |
|
173 | + { |
|
174 | + $this->attributes['status'] = $this->status_message = ''; |
|
175 | + |
|
176 | + return $this; |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * Checks to see if a user has been banned. |
|
181 | + * |
|
182 | + * @return bool |
|
183 | + */ |
|
184 | + public function isBanned(): bool |
|
185 | + { |
|
186 | + return isset($this->attributes['status']) && $this->attributes['status'] === 'banned'; |
|
187 | + } |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Determines whether the user has the appropriate permission, |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | public function can(string $permission) |
198 | 198 | { |
199 | 199 | return in_array(strtolower($permission), $this->getPermissions()); |
200 | - } |
|
200 | + } |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Returns the user's permissions, formatted for simple checking: |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | return $this->roles; |
255 | - } |
|
255 | + } |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Warns the developer it won't work, so they don't spend |
@@ -265,5 +265,5 @@ discard block |
||
265 | 265 | public function setPermissions(array $permissions = null) |
266 | 266 | { |
267 | 267 | throw new \RuntimeException('User entity does not support saving permissions directly.'); |
268 | - } |
|
268 | + } |
|
269 | 269 | } |
@@ -7,71 +7,71 @@ |
||
7 | 7 | */ |
8 | 8 | class Password |
9 | 9 | { |
10 | - /** |
|
11 | - * @param string $password Password |
|
12 | - * |
|
13 | - * @return string |
|
14 | - */ |
|
15 | - public static function hash(string $password): string |
|
16 | - { |
|
17 | - $config = config('Auth'); |
|
10 | + /** |
|
11 | + * @param string $password Password |
|
12 | + * |
|
13 | + * @return string |
|
14 | + */ |
|
15 | + public static function hash(string $password): string |
|
16 | + { |
|
17 | + $config = config('Auth'); |
|
18 | 18 | |
19 | - if ( |
|
20 | - (defined('PASSWORD_ARGON2I') && $config->hashAlgorithm == PASSWORD_ARGON2I) |
|
21 | - || |
|
22 | - (defined('PASSWORD_ARGON2ID') && $config->hashAlgorithm == PASSWORD_ARGON2ID) |
|
23 | - ) |
|
24 | - { |
|
25 | - $hashOptions = [ |
|
26 | - 'memory_cost' => $config->hashMemoryCost, |
|
27 | - 'time_cost' => $config->hashTimeCost, |
|
28 | - 'threads' => $config->hashThreads, |
|
29 | - ]; |
|
30 | - } |
|
31 | - else |
|
32 | - { |
|
33 | - $hashOptions = [ |
|
34 | - 'cost' => $config->hashCost, |
|
35 | - ]; |
|
36 | - } |
|
19 | + if ( |
|
20 | + (defined('PASSWORD_ARGON2I') && $config->hashAlgorithm == PASSWORD_ARGON2I) |
|
21 | + || |
|
22 | + (defined('PASSWORD_ARGON2ID') && $config->hashAlgorithm == PASSWORD_ARGON2ID) |
|
23 | + ) |
|
24 | + { |
|
25 | + $hashOptions = [ |
|
26 | + 'memory_cost' => $config->hashMemoryCost, |
|
27 | + 'time_cost' => $config->hashTimeCost, |
|
28 | + 'threads' => $config->hashThreads, |
|
29 | + ]; |
|
30 | + } |
|
31 | + else |
|
32 | + { |
|
33 | + $hashOptions = [ |
|
34 | + 'cost' => $config->hashCost, |
|
35 | + ]; |
|
36 | + } |
|
37 | 37 | |
38 | - return password_hash( |
|
39 | - self::preparePassword($password), |
|
40 | - $config->hashAlgorithm, |
|
41 | - $hashOptions |
|
42 | - ); |
|
43 | - } |
|
38 | + return password_hash( |
|
39 | + self::preparePassword($password), |
|
40 | + $config->hashAlgorithm, |
|
41 | + $hashOptions |
|
42 | + ); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param string $password Password |
|
47 | - * @param string $hash Hash |
|
48 | - * |
|
49 | - * @return boolean |
|
50 | - */ |
|
51 | - public static function verify(string $password, string $hash): bool |
|
52 | - { |
|
53 | - return password_verify(self::preparePassword($password), $hash); |
|
54 | - } |
|
45 | + /** |
|
46 | + * @param string $password Password |
|
47 | + * @param string $hash Hash |
|
48 | + * |
|
49 | + * @return boolean |
|
50 | + */ |
|
51 | + public static function verify(string $password, string $hash): bool |
|
52 | + { |
|
53 | + return password_verify(self::preparePassword($password), $hash); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param string $hash Hash |
|
58 | - * @param integer|string $algo Hash algorithm |
|
59 | - * @param array $options Options |
|
60 | - * |
|
61 | - * @return boolean |
|
62 | - */ |
|
63 | - public static function needsRehash(string $hash, $algo, array $options = []): bool |
|
64 | - { |
|
65 | - return password_needs_rehash($hash, $algo, $options); |
|
66 | - } |
|
56 | + /** |
|
57 | + * @param string $hash Hash |
|
58 | + * @param integer|string $algo Hash algorithm |
|
59 | + * @param array $options Options |
|
60 | + * |
|
61 | + * @return boolean |
|
62 | + */ |
|
63 | + public static function needsRehash(string $hash, $algo, array $options = []): bool |
|
64 | + { |
|
65 | + return password_needs_rehash($hash, $algo, $options); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param string $password Password |
|
70 | - * |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - protected static function preparePassword(string $password): string |
|
74 | - { |
|
75 | - return base64_encode(hash('sha384', $password, true)); |
|
76 | - } |
|
68 | + /** |
|
69 | + * @param string $password Password |
|
70 | + * |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + protected static function preparePassword(string $password): string |
|
74 | + { |
|
75 | + return base64_encode(hash('sha384', $password, true)); |
|
76 | + } |
|
77 | 77 | } |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | } |
242 | 242 | |
243 | 243 | return array('dirname' => substr($path, 0, $lastSlashPos), |
244 | - 'basename' => substr($path, $lastSlashPos + 1) |
|
245 | - ); |
|
244 | + 'basename' => substr($path, $lastSlashPos + 1) |
|
245 | + ); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | } |
531 | 531 | |
532 | 532 | return $this->doPermChange($path, |
533 | - $content, |
|
534 | - function() use ($content, $var) |
|
535 | - { |
|
536 | - $content->chown($var); |
|
537 | - } |
|
533 | + $content, |
|
534 | + function() use ($content, $var) |
|
535 | + { |
|
536 | + $content->chown($var); |
|
537 | + } |
|
538 | 538 | ); |
539 | 539 | |
540 | 540 | case STREAM_META_GROUP_NAME: |
@@ -546,11 +546,11 @@ discard block |
||
546 | 546 | } |
547 | 547 | |
548 | 548 | return $this->doPermChange($path, |
549 | - $content, |
|
550 | - function() use ($content, $var) |
|
551 | - { |
|
552 | - $content->chgrp($var); |
|
553 | - } |
|
549 | + $content, |
|
550 | + function() use ($content, $var) |
|
551 | + { |
|
552 | + $content->chgrp($var); |
|
553 | + } |
|
554 | 554 | ); |
555 | 555 | |
556 | 556 | case STREAM_META_ACCESS: |
@@ -559,11 +559,11 @@ discard block |
||
559 | 559 | } |
560 | 560 | |
561 | 561 | return $this->doPermChange($path, |
562 | - $content, |
|
563 | - function() use ($content, $var) |
|
564 | - { |
|
565 | - $content->chmod($var); |
|
566 | - } |
|
562 | + $content, |
|
563 | + function() use ($content, $var) |
|
564 | + { |
|
565 | + $content->chmod($var); |
|
566 | + } |
|
567 | 567 | ); |
568 | 568 | |
569 | 569 | default: |
@@ -647,18 +647,18 @@ discard block |
||
647 | 647 | public function stream_stat() |
648 | 648 | { |
649 | 649 | $fileStat = array('dev' => 0, |
650 | - 'ino' => 0, |
|
651 | - 'mode' => $this->content->getType() | $this->content->getPermissions(), |
|
652 | - 'nlink' => 0, |
|
653 | - 'uid' => $this->content->getUser(), |
|
654 | - 'gid' => $this->content->getGroup(), |
|
655 | - 'rdev' => 0, |
|
656 | - 'size' => $this->content->size(), |
|
657 | - 'atime' => $this->content->fileatime(), |
|
658 | - 'mtime' => $this->content->filemtime(), |
|
659 | - 'ctime' => $this->content->filectime(), |
|
660 | - 'blksize' => -1, |
|
661 | - 'blocks' => -1 |
|
650 | + 'ino' => 0, |
|
651 | + 'mode' => $this->content->getType() | $this->content->getPermissions(), |
|
652 | + 'nlink' => 0, |
|
653 | + 'uid' => $this->content->getUser(), |
|
654 | + 'gid' => $this->content->getGroup(), |
|
655 | + 'rdev' => 0, |
|
656 | + 'size' => $this->content->size(), |
|
657 | + 'atime' => $this->content->fileatime(), |
|
658 | + 'mtime' => $this->content->filemtime(), |
|
659 | + 'ctime' => $this->content->filectime(), |
|
660 | + 'blksize' => -1, |
|
661 | + 'blocks' => -1 |
|
662 | 662 | ); |
663 | 663 | return array_merge(array_values($fileStat), $fileStat); |
664 | 664 | } |
@@ -994,18 +994,18 @@ discard block |
||
994 | 994 | } |
995 | 995 | |
996 | 996 | $fileStat = array('dev' => 0, |
997 | - 'ino' => 0, |
|
998 | - 'mode' => $content->getType() | $content->getPermissions(), |
|
999 | - 'nlink' => 0, |
|
1000 | - 'uid' => $content->getUser(), |
|
1001 | - 'gid' => $content->getGroup(), |
|
1002 | - 'rdev' => 0, |
|
1003 | - 'size' => $content->size(), |
|
1004 | - 'atime' => $content->fileatime(), |
|
1005 | - 'mtime' => $content->filemtime(), |
|
1006 | - 'ctime' => $content->filectime(), |
|
1007 | - 'blksize' => -1, |
|
1008 | - 'blocks' => -1 |
|
997 | + 'ino' => 0, |
|
998 | + 'mode' => $content->getType() | $content->getPermissions(), |
|
999 | + 'nlink' => 0, |
|
1000 | + 'uid' => $content->getUser(), |
|
1001 | + 'gid' => $content->getGroup(), |
|
1002 | + 'rdev' => 0, |
|
1003 | + 'size' => $content->size(), |
|
1004 | + 'atime' => $content->fileatime(), |
|
1005 | + 'mtime' => $content->filemtime(), |
|
1006 | + 'ctime' => $content->filectime(), |
|
1007 | + 'blksize' => -1, |
|
1008 | + 'blocks' => -1 |
|
1009 | 1009 | ); |
1010 | 1010 | return array_merge(array_values($fileStat), $fileStat); |
1011 | 1011 | } |
@@ -154,10 +154,10 @@ |
||
154 | 154 | { |
155 | 155 | $this->size = $size; |
156 | 156 | foreach (array_filter(array_keys($this->content), |
157 | - function($pos) use ($size) |
|
158 | - { |
|
159 | - return $pos >= $size; |
|
160 | - } |
|
157 | + function($pos) use ($size) |
|
158 | + { |
|
159 | + return $pos >= $size; |
|
160 | + } |
|
161 | 161 | ) as $removePos) { |
162 | 162 | unset($this->content[$removePos]); |
163 | 163 | } |
@@ -73,8 +73,8 @@ |
||
73 | 73 | protected function doWrite($data, $offset, $length) |
74 | 74 | { |
75 | 75 | $this->content = substr($this->content, 0, $offset) |
76 | - . $data |
|
77 | - . substr($this->content, $offset + $length); |
|
76 | + . $data |
|
77 | + . substr($this->content, $offset + $length); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | public function visitFileWritesFileNameToStream() |
45 | 45 | { |
46 | 46 | $output = vfsStream::newFile('foo.txt') |
47 | - ->at(vfsStream::setup()); |
|
47 | + ->at(vfsStream::setup()); |
|
48 | 48 | $printVisitor = new vfsStreamPrintVisitor(fopen('vfs://root/foo.txt', 'wb')); |
49 | 49 | $this->assertSame($printVisitor, |
50 | - $printVisitor->visitFile(vfsStream::newFile('bar.txt')) |
|
50 | + $printVisitor->visitFile(vfsStream::newFile('bar.txt')) |
|
51 | 51 | ); |
52 | 52 | $this->assertEquals("- bar.txt\n", $output->getContent()); |
53 | 53 | } |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | public function visitFileWritesBlockDeviceToStream() |
59 | 59 | { |
60 | 60 | $output = vfsStream::newFile('foo.txt') |
61 | - ->at(vfsStream::setup()); |
|
61 | + ->at(vfsStream::setup()); |
|
62 | 62 | $printVisitor = new vfsStreamPrintVisitor(fopen('vfs://root/foo.txt', 'wb')); |
63 | 63 | $this->assertSame($printVisitor, |
64 | - $printVisitor->visitBlockDevice(vfsStream::newBlock('bar')) |
|
64 | + $printVisitor->visitBlockDevice(vfsStream::newBlock('bar')) |
|
65 | 65 | ); |
66 | 66 | $this->assertEquals("- [bar]\n", $output->getContent()); |
67 | 67 | } |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | public function visitDirectoryWritesDirectoryNameToStream() |
73 | 73 | { |
74 | 74 | $output = vfsStream::newFile('foo.txt') |
75 | - ->at(vfsStream::setup()); |
|
75 | + ->at(vfsStream::setup()); |
|
76 | 76 | $printVisitor = new vfsStreamPrintVisitor(fopen('vfs://root/foo.txt', 'wb')); |
77 | 77 | $this->assertSame($printVisitor, |
78 | - $printVisitor->visitDirectory(vfsStream::newDirectory('baz')) |
|
78 | + $printVisitor->visitDirectory(vfsStream::newDirectory('baz')) |
|
79 | 79 | ); |
80 | 80 | $this->assertEquals("- baz\n", $output->getContent()); |
81 | 81 | } |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | public function visitRecursiveDirectoryStructure() |
87 | 87 | { |
88 | 88 | $root = vfsStream::setup('root', |
89 | - null, |
|
90 | - array('test' => array('foo' => array('test.txt' => 'hello'), |
|
91 | - 'baz.txt' => 'world' |
|
92 | - ), |
|
93 | - 'foo.txt' => '' |
|
94 | - ) |
|
89 | + null, |
|
90 | + array('test' => array('foo' => array('test.txt' => 'hello'), |
|
91 | + 'baz.txt' => 'world' |
|
92 | + ), |
|
93 | + 'foo.txt' => '' |
|
94 | + ) |
|
95 | 95 | ); |
96 | 96 | $printVisitor = new vfsStreamPrintVisitor(fopen('vfs://root/foo.txt', 'wb')); |
97 | 97 | $this->assertSame($printVisitor, |
98 | - $printVisitor->visitDirectory($root) |
|
98 | + $printVisitor->visitDirectory($root) |
|
99 | 99 | ); |
100 | 100 | $this->assertEquals("- root\n - test\n - foo\n - test.txt\n - baz.txt\n - foo.txt\n", file_get_contents('vfs://root/foo.txt')); |
101 | 101 | } |