GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (38)

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/predaddy/presentation/PageImpl.php (1 issue)

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
 * Copyright (c) 2013 Janos Szurovecz
4
 *
5
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6
 * this software and associated documentation files (the "Software"), to deal in
7
 * the Software without restriction, including without limitation the rights to
8
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
 * of the Software, and to permit persons to whom the Software is furnished to do
10
 * so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be included in all
13
 * copies or substantial portions of the Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
 * SOFTWARE.
22
 */
23
24
namespace predaddy\presentation;
25
26
use ArrayIterator;
27
use IteratorAggregate;
28
use precore\lang\Object;
29
use precore\lang\ObjectInterface;
30
use precore\util\Objects;
31
32
/**
33
 * Default Page implementation.
34
 *
35
 * @author Janos Szurovecz <[email protected]>
36
 */
37
class PageImpl extends Object implements IteratorAggregate, Page
38
{
39
    private $content = [];
40
41
    /**
42
     * @var Pageable
43
     */
44
    private $pageable;
45
46
    /**
47
     * @var int
48
     */
49
    private $total;
50
51
    /**
52
     * @param array $content
53
     * @param Pageable $pageable
54
     * @param int $total Total number of all elements (not just the current page's)
55
     */
56
    public function __construct(array $content, Pageable $pageable = null, $total = null)
57
    {
58
        $this->content = array_merge($this->content, $content);
59
        $this->total = $total === null ? count($content) : $total;
60
        $this->pageable = $pageable;
61
    }
62
63
    /**
64
     * @return array of the records in the current page
65
     */
66
    public function getContent()
67
    {
68
        return $this->content;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->content; (array) is incompatible with the return type declared by the interface predaddy\presentation\Page::getContent of type Traversable.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
69
    }
70
71
    /**
72
     * @return int The page number
73
     */
74
    public function getNumber()
75
    {
76
        return $this->pageable === null
77
            ? 0
78
            : $this->pageable->getPageNumber();
79
    }
80
81
    /**
82
     * @return int size of the content
83
     */
84
    public function getSize()
85
    {
86
        return $this->pageable === null
87
            ? 0
88
            : $this->pageable->getPageSize();
89
    }
90
91
    public function getSort()
92
    {
93
        return $this->pageable === null
94
            ? null
95
            : $this->pageable->getSort();
96
    }
97
98
    public function getTotalElements()
99
    {
100
        return $this->total;
101
    }
102
103
    public function getTotalPages()
104
    {
105
        return $this->getSize() == 0
106
            ? 1
107
            : ceil($this->total / $this->getSize());
108
    }
109
110
    public function hasContent()
111
    {
112
        return count($this->content) !== 0;
113
    }
114
115
    public function hasNextPage()
116
    {
117
        return $this->getNumber() + 1 < $this->getTotalPages();
118
    }
119
120
    public function hasPreviousPage()
121
    {
122
        return 0 < $this->getNumber();
123
    }
124
125
    public function isFirstPage()
126
    {
127
        return !$this->hasPreviousPage();
128
    }
129
130
    public function isLastPage()
131
    {
132
        return !$this->hasNextPage();
133
    }
134
135
    /**
136
     * Create a Pageable object to be able to obtain the next page.
137
     *
138
     * @return Pageable
139
     */
140
    public function nextPageable()
141
    {
142
        return $this->hasNextPage()
143
            ? $this->pageable->next()
144
            : null;
145
    }
146
147
    /**
148
     * Create a Pageable object to be able to obtain the previous page.
149
     *
150
     * @return Pageable
151
     */
152
    public function previousPageable()
153
    {
154
        return $this->hasPreviousPage()
155
            ? $this->pageable->previousOrFirst()
156
            : null;
157
    }
158
159
    /**
160
     * @return ArrayIterator|\Traversable
161
     */
162
    public function getIterator()
163
    {
164
        return new ArrayIterator($this->content);
165
    }
166
167
    public function equals(ObjectInterface $object = null)
168
    {
169
        if ($object === $this) {
170
            return true;
171
        }
172
        /* @var $object PageImpl */
173
        return $object !== null
174
            && $this->getClassName() === $object->getClassName()
175
            && Objects::equal($this->total, $object->total)
176
            && Objects::equal($this->content, $object->content)
177
            && Objects::equal($this->pageable, $object->pageable);
178
    }
179
180
    public function toString()
181
    {
182
        return Objects::toStringHelper($this)
183
            ->add('total', $this->total)
184
            ->add('pageable', $this->pageable)
185
            ->toString();
186
    }
187
}
188