XoopsModules25x /
suico
| 1 | <?php declare(strict_types=1); |
||||
| 2 | /* |
||||
| 3 | You may not change or alter any portion of this comment or credits |
||||
| 4 | of supporting developers from this source code or any supporting source code |
||||
| 5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||
| 6 | |||||
| 7 | This program is distributed in the hope that it will be useful, |
||||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
| 10 | */ |
||||
| 11 | |||||
| 12 | /** |
||||
| 13 | * @category Module |
||||
| 14 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||||
| 15 | * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||||
| 16 | * @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
||||
| 17 | */ |
||||
| 18 | |||||
| 19 | use Xmf\Request; |
||||
|
0 ignored issues
–
show
|
|||||
| 20 | use XoopsModules\Suico\{ |
||||
| 21 | FriendshipHandler |
||||
| 22 | }; |
||||
| 23 | |||||
| 24 | require __DIR__ . '/header.php'; |
||||
| 25 | if (!$xoopsUser) { |
||||
| 26 | redirect_header('index.php'); |
||||
| 27 | } |
||||
| 28 | $friendshipFactory = new FriendshipHandler($xoopsDB); |
||||
| 29 | $friend2_uid = Request::getInt('friend_uid', 0, 'POST'); |
||||
| 30 | $marker = Request::getInt('marker', 0, 'POST'); |
||||
| 31 | $friend = new \XoopsUser($friend2_uid); |
||||
|
0 ignored issues
–
show
$friend2_uid of type integer is incompatible with the type array|null expected by parameter $id of XoopsUser::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 32 | if (1 === $marker) { |
||||
| 33 | $level = $_POST['level']; |
||||
| 34 | $cool = $_POST['cool']; |
||||
| 35 | $friendly = $_POST['hot']; |
||||
| 36 | $funny = $_POST['trust']; |
||||
| 37 | $fan = $_POST['fan']; |
||||
| 38 | $friendship_id = Request::getInt('friendship_id', 0, 'POST'); |
||||
| 39 | $criteria = new Criteria('friendship_id', $friendship_id); |
||||
| 40 | $friendships = $friendshipFactory->getObjects($criteria); |
||||
| 41 | $friendship = $friendships[0]; |
||||
| 42 | $friendship->setVar('level', $level); |
||||
| 43 | $friendship->setVar('cool', $cool); |
||||
| 44 | $friendship->setVar('hot', $friendly); |
||||
| 45 | $friendship->setVar('trust', $funny); |
||||
| 46 | $friendship->setVar('fan', $fan); |
||||
| 47 | $friend2_uid = (int)$friendship->getVar('friend2_uid'); |
||||
| 48 | $friendship->unsetNew(); |
||||
| 49 | $friendshipFactory->insert2($friendship); |
||||
| 50 | redirect_header('friends.php', 2, _MD_SUICO_FRIENDSHIP_UPDATED); |
||||
| 51 | } else { |
||||
| 52 | $friendshipFactory->renderFormSubmit($friend); |
||||
| 53 | } |
||||
| 54 | require \dirname(__DIR__, 2) . '/footer.php'; |
||||
| 55 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: