Global variable or function should never be used 8

More information: https://insight.symfony.com/what-we-analyse/php.use_global_variable_or_function

  1. *
  2. * @param string|null $abstract
  3. *
  4. * @return mixed
  5. */
  6. function app(string $abstract = null)

    app() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Greg Roach
  7. {
  8. if ($abstract === null) {
  9. return Application::getInstance();
  10. }
  • fisharebest

    Ignored on Thu, 07 Mar 2019 11:36:51 GMT
  1. *
  2. * @param string $path
  3. *
  4. * @return string
  5. */
  6. function asset(string $path): string

    asset() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Greg Roach
  7. {
  8. if (substr($path, -1) === '/') {
  9. $version = '';
  10. } elseif (Webtrees::STABILITY === '') {
  11. $version = '?v=' . Webtrees::VERSION;
  • fisharebest

    Ignored on Thu, 07 Mar 2019 11:37:19 GMT
  1. /**
  2. * Generate a CSRF token form field.
  3. *
  4. * @return string
  5. */
  6. function csrf_field()

    csrf_field() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Greg Roach
  7. {
  8. return '<input type="hidden" name="csrf" value="' . e(Session::getCsrfToken()) . '">';
  9. }
  10. /**
  • fisharebest

    Ignored on Thu, 07 Mar 2019 11:36:59 GMT
  1. /**
  2. * Get the CSRF token value.
  3. *
  4. * @return string
  5. */
  6. function csrf_token()

    csrf_token() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Greg Roach
  7. {
  8. return Session::getCsrfToken();
  9. }
  10. /**
  • fisharebest

    Ignored on Thu, 07 Mar 2019 11:37:43 GMT
  1. * @param string $url
  2. * @param int $code
  3. *
  4. * @return ResponseInterface
  5. */
  6. function redirect(string $url, $code = StatusCodeInterface::STATUS_FOUND): ResponseInterface

    redirect() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Greg Roach
  7. {
  8. /** @var ResponseFactoryInterface $response_factory */
  9. $response_factory = app(ResponseFactoryInterface::class);
  10. return $response_factory
  • fisharebest

    Ignored on Wed, 10 Apr 2019 10:14:48 GMT
  1. * @param int $code
  2. * @param string[] $headers
  3. *
  4. * @return ResponseInterface
  5. */
  6. function response($content = '', $code = StatusCodeInterface::STATUS_OK, $headers = []): ResponseInterface

    response() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Greg Roach
  7. {
  8. if ($headers === []) {
  9. if (is_string($content)) {
  10. $headers = [
  11. 'Content-Type' => 'text/html; charset=utf-8',
  • fisharebest

    Ignored on Wed, 10 Apr 2019 13:14:12 GMT
  1. * @param array $parameters
  2. * @param bool $absolute
  3. *
  4. * @return string
  5. */
  6. function route(string $route, array $parameters = [], bool $absolute = true): string

    route() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Greg Roach
  7. {
  8. $parameters = ['route' => $route] + $parameters;
  9. if ($absolute) {
  10. $base_url = app(ServerRequestInterface::class)->getAttribute('base_url');
  • fisharebest

    Ignored on Thu, 07 Mar 2019 11:37:06 GMT
  1. * @param string $name
  2. * @param mixed[] $data
  3. *
  4. * @return string
  5. */
  6. function view(string $name, array $data = [])

    view() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Greg Roach
  7. {
  8. return WebtreesView::make($name, $data);
  9. }
  • fisharebest

    Ignored on Thu, 07 Mar 2019 11:36:22 GMT

Commented code should not be committed 7

More information: https://insight.symfony.com/what-we-analyse/php.commented_out_code

  1. */
  2. public function customTranslations(string $language): array
  3. {
  4. // Here we are using an array for translations.
  5. // If you had .MO files, you could use them with:
  6. // return (new Translation('path/to/file.mo'))->asArray();

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Greg Roach
  7. switch ($language) {
  8. case 'en-AU':
  9. case 'en-GB':
  10. case 'en-US':
  • fisharebest

    Ignored on Thu, 14 Mar 2019 21:09:07 GMT
  1. //
  2. // Typical webservers will not wait more than 60 seconds for a PHP response,
  3. // so it is pointless to allow the server to continue using resources for
  4. // a request that will be ignored.
  5. //set_time_limit(45);

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Greg Roach
  6. }
  7. /**
  8. * Modify the PHP environment variables.
  9. */
  • fisharebest

    d on Thu, 07 Mar 2019 12:17:34 GMT
  1. private function phpEnvironment(): void
  2. {
  3. // Some servers block access to the system temporary folder using open_basedir...
  4. //
  5. // Create a temporary folder somewhere we have read/write access, and tell PHP to use it.
  6. //$tmp = __DIR__ . '/../../data/tmp';

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Greg Roach
  7. //if (!is_dir($tmp)) {
  8. // mkdir($tmp);
  9. //}
  10. //putenv('TMPDIR=' . $tmp);
  11. }
  • fisharebest

    Ignored on Thu, 14 Mar 2019 21:09:45 GMT
  1. // Some servers block access to the system temporary folder using open_basedir...
  2. //
  3. // Create a temporary folder somewhere we have read/write access, and tell PHP to use it.
  4. //$tmp = __DIR__ . '/../../data/tmp';
  5. //if (!is_dir($tmp)) {
  6. // mkdir($tmp);

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Greg Roach
  7. //}
  8. //putenv('TMPDIR=' . $tmp);
  9. }
  10. /**
  • fisharebest

    Ignored on Thu, 14 Mar 2019 21:09:14 GMT
  1. // Create a temporary folder somewhere we have read/write access, and tell PHP to use it.
  2. //$tmp = __DIR__ . '/../../data/tmp';
  3. //if (!is_dir($tmp)) {
  4. // mkdir($tmp);
  5. //}
  6. //putenv('TMPDIR=' . $tmp);

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Greg Roach
  7. }
  8. /**
  9. * Modify the PHP.INI settings.
  10. */
  • fisharebest

    Ignored on Thu, 14 Mar 2019 21:09:53 GMT
  1. private function phpIni(): void
  2. {
  3. // Set the maximum amount of memory that PHP scripts can use.
  4. // Recommended settings are between 128M and 1024M
  5. //ini_set('memory_limit', '256M');

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Greg Roach
  6. }
  7. /**
  8. * Modify the MySQL connection.
  9. */
  • fisharebest

    Ignored on Thu, 07 Mar 2019 12:17:52 GMT
  1. private function mysql(): void
  2. {
  3. // If you get the error "The SELECT would examine more than MAX_JOIN_SIZE rows",
  4. // then setting this option may help.
  5. //DB::statement('SET SESSION sql_big_selects := 1');

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Greg Roach
  6. }
  7. };
  • fisharebest

    Ignored on Thu, 07 Mar 2019 12:17:44 GMT

Unused method, property, variable or parameter 3

More information: https://insight.symfony.com/what-we-analyse/php.unused_local_variable_or_private_member

  1. * @param string $name The name of the xml element parsed
  2. * @param string[] $attrs An array of key value pairs for the attributes
  3. *
  4. * @return void
  5. */
  6. protected function startElement($parser, string $name, array $attrs): void

    This parser argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Greg Roach
  7. {
  8. $method = $name . 'StartHandler';
  9. if (method_exists($this, $method)) {
  10. $this->$method($attrs);
  • fisharebest

    Ignored on Mon, 06 May 2019 15:33:45 GMT
  1. * @param resource $parser the resource handler for the xml parser
  2. * @param string $name the name of the xml element parsed
  3. *
  4. * @return void
  5. */
  6. protected function endElement($parser, string $name): void

    This parser argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Greg Roach
  7. {
  8. $method = $name . 'EndHandler';
  9. if (method_exists($this, $method)) {
  10. $this->$method();
  • fisharebest

    Ignored on Mon, 06 May 2019 15:33:59 GMT
  1. * @param resource $parser The resource handler for the xml parser
  2. * @param string $data The name of the xml element parsed
  3. *
  4. * @return void
  5. */
  6. protected function characterData($parser, $data): void

    This parser argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Greg Roach
  7. {
  8. $this->text .= $data;
  9. }
  10. }
  • fisharebest

    Ignored on Mon, 06 May 2019 15:33:54 GMT