Issues (4)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/View.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace CodexShaper\Blade;
4
5
use Illuminate\Container\Container;
6
use Illuminate\Contracts\Container\Container as ContainerContract;
7
use Illuminate\Events\Dispatcher;
8
use Illuminate\Filesystem\Filesystem;
9
use Illuminate\Support\Facades\Facade;
10
use Illuminate\View\ViewServiceProvider;
11
12
class View
13
{
14
    /**
15
     * @var
16
     */
17
    protected $app;
18
19
    /**
20
     * @var
21
     */
22
    private $view;
23
24
    /**
25
     * @var
26
     */
27
    private $viewPaths;
28
29
    /**
30
     * @var
31
     */
32
    private $cachePath;
33
34
    /**
35
     * Create view factory instance if not exists.
36
     *
37
     * @param array                                          $views
38
     * @param string                                         $cache
39
     * @param \Illuminate\Contracts\Container\Container|null $container
40
     *
41
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
42
     */
43
    public function __construct($views = [], $cache = '', ContainerContract $container = null)
44
    {
45
        $this->app = $container;
46
47
        if (is_null($this->app)) {
48
            if (!is_array($views)) {
49
                $views = (array) $views;
50
            }
51
52
            $this->viewPaths = $views;
53
            $this->cachePath = $cache;
54
55
            $this->app = $container ?? new Container();
56
            Facade::setFacadeApplication($this->app);
0 ignored issues
show
$this->app of type object<Illuminate\Contracts\Container\Container> is not a sub-type of object<Illuminate\Contra...Foundation\Application>. It seems like you assume a child interface of the interface Illuminate\Contracts\Container\Container to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
57
58
            // Check this files, events and config is binding with shared or not. If not then bind
59
            $this->registerFileSystem();
60
            $this->registerEvents();
61
            $this->registerConfig();
62
63
            // Make sure files, events and config are register before call register
64
            with(new ViewServiceProvider($this->app))->register();
0 ignored issues
show
$this->app of type object<Illuminate\Contracts\Container\Container> is not a sub-type of object<Illuminate\Contra...Foundation\Application>. It seems like you assume a child interface of the interface Illuminate\Contracts\Container\Container to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
65
        }
66
67
        $this->view = $this->app['view'];
68
    }
69
70
    /**
71
     * Bind files calss if not exists.
72
     *
73
     * @return void
74
     */
75
    protected function registerFileSystem()
76
    {
77
        $this->app->bindIf('files', function () {
78
            return new Filesystem();
79
        }, true);
80
    }
81
82
    /**
83
     * Bind events calss if not exists.
84
     *
85
     * @return void
86
     */
87
    protected function registerEvents()
88
    {
89
        $this->app->bindIf('events', function () {
90
            return new Dispatcher();
91
        }, true);
92
    }
93
94
    /**
95
     * Bind config calss if not exists.
96
     *
97
     * @return void
98
     */
99
    protected function registerConfig()
100
    {
101
        if (!is_array($this->viewPaths)) {
102
            throw new \Exception('Views path must be array');
103
        }
104
105
        $self = $this;
106
107
        $this->app->bindIf('config', function () use ($self) {
108
            return [
109
                'view.paths'    => $self->viewPaths,
110
                'view.compiled' => $self->cachePath,
111
            ];
112
        }, true);
113
    }
114
115
    /**
116
     * Get blade compiler.
117
     *
118
     * @return \Illuminate\View\Compilers\BladeCompiler
119
     */
120
    public function blade()
121
    {
122
        return $this->app['blade.compiler'];
123
    }
124
125
    /**
126
     * Call view factory methods dynamically.
127
     *
128
     * @param string $method
129
     * @param array  $parameters
130
     *
131
     * @return \Illuminate\View\View|\BadMethodCallException
132
     */
133
    public function __call($method, $parameters)
134
    {
135
        if (!method_exists(new self(), $method) && method_exists($this->view, $method)) {
136
            return call_user_func_array([$this->view, $method], $parameters);
137
        }
138
139
        return $this->$method(...$parameters);
140
    }
141
142
    /**
143
     * Call view factory methods statically.
144
     *
145
     * @param string $method
146
     * @param array  $parameters
147
     *
148
     * @return \Illuminate\View\View|\BadMethodCallException
149
     */
150
    public static function __callStatic($method, $parameters)
151
    {
152
        if (!method_exists(new static(), $method) && method_exists($this->view, $method)) {
153
            return forward_static_call_array([$this->view, $method], $parameters);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
154
        }
155
156
        return (new static() )->$method(...$parameters);
157
    }
158
}
159