Completed
Pull Request — master (#20)
by Anatoliy
29:38 queued 19:40
created

ResourceTypeMock::getSample()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Created by PhpStorm.
5
 * User: danchukas
6
 * Date: 2017-07-18 08:46
7
 */
8
9
namespace DanchukAS\Mock\Type;
10
11
12
use DanchukAS\Mock\TypeMock;
13
14
/**
15
 * Class ResourceTypeMock
16
 * @package DanchukAS\Mock\Type
17
 */
18
class ResourceTypeMock extends TypeMock
19
{
20
    static $lastResource;
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $lastResource.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
21
22
    /**
23
     * @return \Generator
24
     */
25
    public static function getSample()
26
    {
27
28
        $resource = sem_get(1);
29
        yield ["native memory" => $resource];
30
31
32
// @todo: add native res
33
//        $r = 	opendir();
34
//        $r = shmop_open();
35
36
//        shm_attach();
37
//        xml_parser_create();
38
//        gzopen();
39
40
41
        if (function_exists("imagecreate")) {
42
            $resource = \imagecreate(1, 1);
43
            yield $resource;
44
            @\imagedestroy($resource);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for imagedestroy(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

44
            /** @scrutinizer ignore-unhandled */ @\imagedestroy($resource);

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.');
}
Loading history...
45
        }
46
    }
47
}