mambax7 /
pedigree
| 1 | <?php namespace XoopsModules\Pedigree; |
||||
|
0 ignored issues
–
show
|
|||||
| 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 | * Pedigree module for XOOPS |
||||
| 13 | * |
||||
| 14 | * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} |
||||
| 15 | * @license GPL 2.0 or later |
||||
| 16 | * @package pedigree |
||||
| 17 | * @since |
||||
| 18 | * @author XOOPS Module Dev Team (https://xoops.org) |
||||
| 19 | */ |
||||
| 20 | |||||
| 21 | use XoopsModules\Pedigree; |
||||
|
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
XoopsModules\Pedigree\Pedigree. Consider defining an alias.
Let?s assume that you have a directory layout like this: .
|-- OtherDir
| |-- Bar.php
| `-- Foo.php
`-- SomeDir
`-- Foo.php
and let?s assume the following content of // Bar.php
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
|
|||||
| 22 | |||||
| 23 | defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||||
| 24 | |||||
| 25 | /** |
||||
| 26 | * Class Pedigree\Tree |
||||
| 27 | */ |
||||
| 28 | class Tree extends \XoopsObject |
||||
| 29 | { |
||||
| 30 | //Constructor |
||||
| 31 | /** |
||||
| 32 | * |
||||
| 33 | */ |
||||
| 34 | public function __construct() |
||||
| 35 | { |
||||
| 36 | parent::__construct(); |
||||
| 37 | $this->initVar('id', XOBJ_DTYPE_INT, null, false, 7); |
||||
| 38 | $this->initVar('naam', XOBJ_DTYPE_TXTAREA, null, false); |
||||
| 39 | $this->initVar('id_owner', XOBJ_DTYPE_INT, null, false, 5); |
||||
| 40 | $this->initVar('id_breeder', XOBJ_DTYPE_INT, null, false, 5); |
||||
| 41 | $this->initVar('user', XOBJ_DTYPE_TXTBOX, null, false, 25); |
||||
| 42 | $this->initVar('roft', XOBJ_DTYPE_ENUM, null, false); |
||||
| 43 | $this->initVar('mother', XOBJ_DTYPE_INT, null, false, 5); |
||||
| 44 | $this->initVar('father', XOBJ_DTYPE_INT, null, false, 5); |
||||
| 45 | $this->initVar('foto', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||||
| 46 | $this->initVar('coi', XOBJ_DTYPE_TXTBOX, null, false, 10); |
||||
| 47 | } |
||||
| 48 | |||||
| 49 | /** |
||||
| 50 | * @param bool $action |
||||
| 51 | * |
||||
| 52 | * @return \XoopsThemeForm |
||||
| 53 | */ |
||||
| 54 | public function getForm($action = false) |
||||
| 55 | { |
||||
| 56 | //global $xoopsModuleConfig; |
||||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
75% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||||
| 57 | |||||
| 58 | if (false === $action) { |
||||
| 59 | $action = $_SERVER['REQUEST_URI']; |
||||
| 60 | } |
||||
| 61 | |||||
| 62 | $title = $this->isNew() ? sprintf(_AM_PEDIGREE_PEDIGREE_ADD) : sprintf(_AM_PEDIGREE_PEDIGREE_EDIT); |
||||
| 63 | |||||
| 64 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||||
| 65 | |||||
| 66 | $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
||||
| 67 | $form->setExtra('enctype="multipart/form-data"'); |
||||
| 68 | |||||
| 69 | $form->addElement(new \XoopsFormTextArea(_AM_PEDIGREE_PEDIGREE_NAAM, 'naam', $this->getVar('naam'), 4, 47), true); |
||||
|
0 ignored issues
–
show
It seems like
$this->getVar('naam') can also be of type array and array; however, parameter $value of XoopsFormTextArea::__construct() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 70 | $form->addElement(new \XoopsFormText(_AM_PEDIGREE_PEDIGREE_ID_OWNER, 'id_owner', 50, 255, $this->getVar('id_owner')), false); |
||||
|
0 ignored issues
–
show
It seems like
$this->getVar('id_owner') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 71 | $form->addElement(new \XoopsFormText(_AM_PEDIGREE_PEDIGREE_ID_BREEDER, 'id_breeder', 50, 255, $this->getVar('id_breeder')), false); |
||||
| 72 | $form->addElement(new \XoopsFormText(_AM_PEDIGREE_PEDIGREE_USER, 'user', 50, 255, $this->getVar('user')), false); |
||||
| 73 | $form->addElement(new \XoopsFormTextArea(_AM_PEDIGREE_PEDIGREE_ROFT, 'roft', $this->getVar('roft'), 4, 47), false); |
||||
| 74 | $form->addElement(new \XoopsFormText(_AM_PEDIGREE_PEDIGREE_MOTHER, 'mother', 50, 255, $this->getVar('mother')), false); |
||||
| 75 | $form->addElement(new \XoopsFormText(_AM_PEDIGREE_PEDIGREE_FATHER, 'father', 50, 255, $this->getVar('father')), false); |
||||
| 76 | $form->addElement(new \XoopsFormText(_AM_PEDIGREE_PEDIGREE_FOTO, 'foto', 50, 255, $this->getVar('foto')), false); |
||||
| 77 | $form->addElement(new \XoopsFormText(_AM_PEDIGREE_PEDIGREE_COI, 'coi', 50, 255, $this->getVar('coi')), false); |
||||
| 78 | |||||
| 79 | $form->addElement(new \XoopsFormHidden('op', 'save_pedigree')); |
||||
| 80 | |||||
| 81 | //Submit buttons |
||||
| 82 | $button_tray = new \XoopsFormElementTray('', ''); |
||||
| 83 | $submit_button = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
||||
| 84 | $button_tray->addElement($submit_button); |
||||
| 85 | |||||
| 86 | $cancel_button = new \XoopsFormButton('', '', _CANCEL, 'cancel'); |
||||
| 87 | $cancel_button->setExtra('onclick="history.go(-1)"'); |
||||
| 88 | $button_tray->addElement($cancel_button); |
||||
| 89 | |||||
| 90 | $form->addElement($button_tray); |
||||
| 91 | |||||
| 92 | return $form; |
||||
| 93 | } |
||||
| 94 | } |
||||
| 95 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.