Issues (29)

prefixes/nestedset_prefixes.php (4 issues)

1
<?php
2
/**
3
 *
4
 * Topic Prefixes extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2016 phpBB Limited <https://www.phpbb.com>
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace phpbb\topicprefixes\prefixes;
12
13
/**
14
 * Nested set class for Topic Prefixes
15
 */
16
class nestedset_prefixes extends \phpbb\tree\nestedset
0 ignored issues
show
The type phpbb\tree\nestedset was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
{
18
	/**
19
	 * Construct
20
	 *
21
	 * @param \phpbb\db\driver\driver_interface $db         Database connection
22
	 * @param \phpbb\lock\db                    $lock       Lock class used to lock the table when moving forums around
23
	 * @param string                            $table_name Table name
24
	 */
25
	public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\lock\db $lock, $table_name)
0 ignored issues
show
The type phpbb\db\driver\driver_interface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
The type phpbb\lock\db was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
	{
27
		parent::__construct(
28
			$db,
29
			$lock,
30
			$table_name,
31
			'TOPIC_PREFIXES_',
32
			'',
33
			[],
34
			[
35
				'item_id'		=> 'prefix_id',
36
				'parent_id'		=> 'prefix_parent_id',
37
				'left_id'		=> 'prefix_left_id',
38
				'right_id'		=> 'prefix_right_id',
39
				'item_parents'	=> 'prefix_parents',
40
			]
41
		);
42
	}
43
44
	/**
45
	 * Set additional sql where restrictions to use the forum id
46
	 *
47
	 * @param int $forum_id The forum identifier
48
	 * @return nestedset_prefixes $this object for chaining calls
49
	 */
50
	public function where_forum_id($forum_id)
51
	{
52
		$this->sql_where = '%sforum_id = ' . (int) $forum_id;
0 ignored issues
show
Bug Best Practice introduced by
The property sql_where does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
53
54
		return $this;
55
	}
56
57
	/**
58
	 * Update a nested item
59
	 *
60
	 * @param int   $item_id   The item identifier
61
	 * @param array $item_data SQL array of data to update
62
	 * @return mixed Number of the affected rows updated, or false
63
	 * @throws \OutOfBoundsException
64
	 */
65
	public function update_item($item_id, array $item_data)
66
	{
67
		if (!$item_id)
68
		{
69
			throw new \OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
70
		}
71
72
		$sql = 'UPDATE ' . $this->table_name . '
73
			SET ' . $this->db->sql_build_array('UPDATE', $item_data) . '
74
			WHERE ' . $this->column_item_id . ' = ' . (int) $item_id;
75
		$this->db->sql_query($sql);
76
77
		return $this->db->sql_affectedrows();
78
	}
79
}
80