These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | |||
3 | /* |
||
4 | * This file is part of the FOSHttpCacheBundle package. |
||
5 | * |
||
6 | * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace FOS\HttpCacheBundle; |
||
13 | |||
14 | use FOS\HttpCache\SymfonyCache\CacheEvent; |
||
15 | use FOS\HttpCache\SymfonyCache\UserContextSubscriber; |
||
16 | use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache as BaseHttpCache; |
||
17 | use Symfony\Component\HttpFoundation\Request; |
||
18 | use Symfony\Component\HttpKernel\HttpKernelInterface; |
||
19 | |||
20 | 1 | @trigger_error('The '.__NAMESPACE__.'\HttpCache class is deprecated since version 1.2 and will be removed in 2.0. Use FOS\HttpCacheBundle\SymfonyCache\EventDispatchingHttpCache instead.', E_USER_DEPRECATED); |
|
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||
21 | |||
22 | /** |
||
23 | * Base class for enhanced Symfony reverse proxy based on the symfony FrameworkBundle HttpCache. |
||
24 | * |
||
25 | * @deprecated Use FOS\HttpCacheBundle\SymfonyCache\EventDispatchingHttpCache instead |
||
26 | * |
||
27 | * @author Jérôme Vieilledent <[email protected]> (courtesy of eZ Systems AS) |
||
28 | * |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | abstract class HttpCache extends BaseHttpCache |
||
32 | { |
||
33 | /** |
||
34 | * Hash for anonymous user. |
||
35 | * |
||
36 | * @deprecated Use the options on UserContextSubscriber instead |
||
37 | */ |
||
38 | const ANONYMOUS_HASH = '38015b703d82206ebc01d17a39c727e5'; |
||
39 | |||
40 | /** |
||
41 | * Accept header value to be used to request the user hash to the backend application. |
||
42 | * It must match the one defined in FOSHttpCacheBundle's configuration. |
||
43 | * |
||
44 | * @deprecated Use the options on UserContextSubscriber instead |
||
45 | */ |
||
46 | const USER_HASH_ACCEPT_HEADER = 'application/vnd.fos.user-context-hash'; |
||
47 | |||
48 | /** |
||
49 | * Name of the header the user context hash will be stored into. |
||
50 | * It must match the one defined in FOSHttpCacheBundle's configuration. |
||
51 | * |
||
52 | * @deprecated Use the options on UserContextSubscriber instead |
||
53 | */ |
||
54 | const USER_HASH_HEADER = 'X-User-Context-Hash'; |
||
55 | |||
56 | /** |
||
57 | * URI used with the forwarded request for user context hash generation. |
||
58 | * |
||
59 | * @deprecated Use the options on UserContextSubscriber instead |
||
60 | */ |
||
61 | const USER_HASH_URI = '/_fos_user_context_hash'; |
||
62 | |||
63 | /** |
||
64 | * HTTP Method used with the forwarded request for user context hash generation. |
||
65 | * |
||
66 | * @deprecated Use the options on UserContextSubscriber instead |
||
67 | */ |
||
68 | const USER_HASH_METHOD = 'GET'; |
||
69 | |||
70 | /** |
||
71 | * Prefix for session names. |
||
72 | * Must match your session configuration. |
||
73 | * |
||
74 | * @deprecated Use the options on UserContextSubscriber instead |
||
75 | */ |
||
76 | const SESSION_NAME_PREFIX = 'PHPSESSID'; |
||
77 | |||
78 | /** |
||
79 | * @var UserContextSubscriber |
||
80 | */ |
||
81 | private $subscriber; |
||
82 | |||
83 | 4 | public function __construct(HttpKernelInterface $kernel, $cacheDir = null) |
|
84 | { |
||
85 | 4 | parent::__construct($kernel, $cacheDir); |
|
86 | |||
87 | 4 | $this->subscriber = new UserContextSubscriber(array( |
|
88 | 4 | 'anonymous_hash' => static::ANONYMOUS_HASH, |
|
0 ignored issues
–
show
The constant
FOS\HttpCacheBundle\HttpCache::ANONYMOUS_HASH has been deprecated with message: Use the options on UserContextSubscriber instead
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead. ![]() |
|||
89 | 4 | 'user_hash_accept_header' => static::USER_HASH_ACCEPT_HEADER, |
|
0 ignored issues
–
show
The constant
FOS\HttpCacheBundle\Http...USER_HASH_ACCEPT_HEADER has been deprecated with message: Use the options on UserContextSubscriber instead
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead. ![]() |
|||
90 | 4 | 'user_hash_header' => static::USER_HASH_HEADER, |
|
0 ignored issues
–
show
The constant
FOS\HttpCacheBundle\HttpCache::USER_HASH_HEADER has been deprecated with message: Use the options on UserContextSubscriber instead
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead. ![]() |
|||
91 | 4 | 'user_hash_uri' => static::USER_HASH_URI, |
|
0 ignored issues
–
show
The constant
FOS\HttpCacheBundle\HttpCache::USER_HASH_URI has been deprecated with message: Use the options on UserContextSubscriber instead
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead. ![]() |
|||
92 | 4 | 'user_hash_method' => static::USER_HASH_METHOD, |
|
0 ignored issues
–
show
The constant
FOS\HttpCacheBundle\HttpCache::USER_HASH_METHOD has been deprecated with message: Use the options on UserContextSubscriber instead
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead. ![]() |
|||
93 | 4 | 'session_name_prefix' => static::SESSION_NAME_PREFIX, |
|
0 ignored issues
–
show
The constant
FOS\HttpCacheBundle\HttpCache::SESSION_NAME_PREFIX has been deprecated with message: Use the options on UserContextSubscriber instead
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead. ![]() |
|||
94 | )); |
||
95 | 4 | } |
|
96 | |||
97 | 4 | public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) |
|
98 | { |
||
99 | 4 | $event = new CacheEvent($this, $request); |
|
100 | 4 | $this->subscriber->preHandle($event); |
|
101 | 4 | if ($event->getResponse()) { |
|
102 | 2 | return $event->getResponse(); |
|
103 | } |
||
104 | |||
105 | 2 | return parent::handle($request, $type, $catch); |
|
106 | } |
||
107 | } |
||
108 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.