PHP debug statements found

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

  1. }
  2. // use var_dump to get the property names
  3. // get_object_vars() doesn't work
  4. $iniWas = \ini_set('xdebug.overload_var_dump', false);
  5. \ob_start();
  6. \var_dump($obj);

    var_dump() should only be used for debug, and not committed to the source code repository.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. $dump = \ob_get_clean();
  8. \ini_set('xdebug.overload_var_dump', $iniWas);
  9. \preg_match_all('/^\s+\["(.*?)"\]=>\n/sm', $dump, $matches);
  10. $props = \array_fill_keys($matches[1], null);
  • bkdotcom

    Debug statements in a debug library??... only way to get DOMNode properties
  • bkdotcom

    Ignored on Thu, 15 Aug 2019 13:45:18 GMT

PHP configuration should not be changed dynamically 5

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

  1. if (!$this->isDomObj($obj)) {
  2. return;
  3. }
  4. // use var_dump to get the property names
  5. // get_object_vars() doesn't work
  6. $iniWas = \ini_set('xdebug.overload_var_dump', false);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Brad Kent
  7. \ob_start();
  8. \var_dump($obj);
  9. $dump = \ob_get_clean();
  10. \ini_set('xdebug.overload_var_dump', $iniWas);
  11. \preg_match_all('/^\s+\["(.*?)"\]=>\n/sm', $dump, $matches);
  • bkdotcom

    ... we restore the config
  • bkdotcom

    Ignored on Thu, 15 Aug 2019 13:46:18 GMT
  1. // get_object_vars() doesn't work
  2. $iniWas = \ini_set('xdebug.overload_var_dump', false);
  3. \ob_start();
  4. \var_dump($obj);
  5. $dump = \ob_get_clean();
  6. \ini_set('xdebug.overload_var_dump', $iniWas);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Brad Kent
  7. \preg_match_all('/^\s+\["(.*?)"\]=>\n/sm', $dump, $matches);
  8. $props = \array_fill_keys($matches[1], null);
  9. if ($obj instanceof \DOMNode) {
  10. $props = \array_merge($props, array(
  • bkdotcom

    Ignored on Thu, 15 Aug 2019 13:46:31 GMT
  1. /*
  2. Disable OPcache
  3. a) want to make sure we modify required files
  4. b) don't want to cache modified files
  5. */
  6. \ini_set('opcache.enable', 0);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Brad Kent
  7. }
  8. /**
  9. * Restore previous wrapper
  10. *
  • bkdotcom

    Au contraire. having opcache enabled when tweaking scripts on the fly caused bizzaro behavior
  • bkdotcom

    Ignored on Mon, 03 Dec 2018 16:26:23 GMT
  1. public function register()
  2. {
  3. if ($this->registered) {
  4. return;
  5. }
  6. $this->prevDisplayErrors = \ini_set('display_errors', 0);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Brad Kent
  7. $this->prevErrorHandler = \set_error_handler(array($this, 'handleError'));
  8. $this->prevExceptionHandler = \set_exception_handler(array($this, 'handleException'));
  9. $this->registered = true; // used by this->onShutdown()
  10. return;
  11. }
  • bkdotcom

    Ignored on Sun, 25 Mar 2018 04:00:07 GMT
  1. \restore_exception_handler();
  2. if ($exHandlerCur == array($this, 'handleException')) {
  3. // we are the current exception handler
  4. \restore_exception_handler();
  5. }
  6. \ini_set('display_errors', $this->prevDisplayErrors);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Brad Kent
  7. $this->prevErrorHandler = null;
  8. $this->prevExceptionHandler = null;
  9. $this->registered = false; // used by $this->onShutdown()
  10. return;
  11. }
  • bkdotcom

    Ignored on Sun, 25 Mar 2018 04:00:22 GMT

Error silenced by the at sign (@) 4

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

  1. self::restorePrev();
  2. if (!\file_exists($path)) {
  3. $info = false;
  4. } elseif ($flags & STREAM_URL_STAT_LINK) {
  5. $info = $flags & STREAM_URL_STAT_QUIET
  6. ? @\lstat($path)

    Adding "@" before \lstat($path) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Brad Kent
  7. : \lstat($path);
  8. } else {
  9. $info = $flags & STREAM_URL_STAT_QUIET
  10. ? @\stat($path)
  11. : \stat($path);
  • bkdotcom

    Ignored on Thu, 11 Oct 2018 04:09:03 GMT
  • bkdotcom

    ignored per StreamWrapper prototype
  1. $info = $flags & STREAM_URL_STAT_QUIET
  2. ? @\lstat($path)
  3. : \lstat($path);
  4. } else {
  5. $info = $flags & STREAM_URL_STAT_QUIET
  6. ? @\stat($path)

    Adding "@" before \stat($path) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Brad Kent
  7. : \stat($path);
  8. }
  9. self::register();
  10. return $info;
  11. }
  • bkdotcom

    Ignored on Thu, 11 Oct 2018 04:09:13 GMT
  • bkdotcom

    ignored per StreamWrapper prototype
  1. private function getParamDefaultVal(ReflectionParameter $reflectionParameter)
  2. {
  3. $defaultValue = Abstracter::UNDEFINED;
  4. if ($reflectionParameter->isDefaultValueAvailable()) {
  5. // suppressing following to avoid "Use of undefined constant STDERR" type notice
  6. $defaultValue = @$reflectionParameter->getDefaultValue();

    Adding "@" before $reflectionParameter->getDefaultValue() prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Brad Kent
  7. if (\version_compare(PHP_VERSION, '5.4.6', '>=') && $reflectionParameter->isDefaultValueConstant()) {
  8. /*
  9. getDefaultValueConstantName() :
  10. php may return something like self::CONSTANT_NAME
  11. hhvm will return WhateverTheClassNameIs::CONSTANT_NAME
  • bkdotcom

    // to avoid "Use of undefined constant STDERR" type notice
  • bkdotcom

    Ignored on Thu, 15 Aug 2019 13:46:54 GMT
  1. if ($type instanceof \ReflectionNamedType) {
  2. $type = $type->getName();
  3. } elseif ($type) {
  4. $type = (string) $type;
  5. }
  6. } elseif (\preg_match('/\[\s<\w+>\s([\w\\\\]+)/s', @$reflectionParameter->__toString(), $matches)) {

    Adding "@" before $reflectionParameter->__toString() prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Brad Kent
  7. // suppressed error to avoid "Use of undefined constant STDERR" type notice
  8. // Parameter #0 [ <required> namespace\Type $varName ]
  9. $type = $matches[1];
  10. }
  11. if (!$type && isset($phpDoc['type'])) {
  • bkdotcom

    // to avoid "Use of undefined constant STDERR" type notice
  • bkdotcom

    Ignored on Thu, 15 Aug 2019 13:47:41 GMT

Object parameters should be type hinted

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

  1. *
  2. * @param Exception|Throwable $exception exception to handle
  3. *
  4. * @return void
  5. */
  6. public function handleException($exception)

    The parameter exception, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. // lets store the exception so we can use the backtrace it provides
  9. // error constructor will pull this
  10. $this->data['uncaughtException'] = $exception;
  11. \http_response_code(500);
  • bkdotcom

    http://php.net/manual/en/function.set-exception-handler.php
    Note that providing an explicit Exception type hint for the ex parameter in your callback will cause issues with the changed exception hierarchy in PHP 7.
  • bkdotcom

    Ignored on Sun, 25 Mar 2018 04:01:17 GMT

PHP code should follow PSR-1 basic coding standard 22

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

  1. *
  2. * @return boolean
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.dir-closedir.php
  5. */
  6. public function dir_closedir()

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if (!$this->handle) {
  9. return false;
  10. }
  11. self::restorePrev();
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:01:25 GMT
  1. *
  2. * @return boolean
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.dir-opendir.php
  5. */
  6. public function dir_opendir($path, $options = 0)

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if ($this->handle) {
  9. return false;
  10. }
  11. // "use" our function params so things don't complain
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:03:42 GMT
  1. *
  2. * @return string|boolean
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.dir-readdir.php
  5. */
  6. public function dir_readdir()

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if (!$this->handle) {
  9. return false;
  10. }
  11. self::restorePrev();
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:03:22 GMT
  1. *
  2. * @return boolean
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.dir-rewinddir.php
  5. */
  6. public function dir_rewinddir()

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if (!$this->handle) {
  9. return false;
  10. }
  11. self::restorePrev();
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:03:16 GMT
  1. *
  2. * @return resource|boolean
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.stream-cast.php
  5. */
  6. public function stream_cast($castAs)

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if ($this->handle && $castAs & STREAM_CAST_AS_STREAM) {
  9. return $this->handle;
  10. }
  11. return false;
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:03:08 GMT
  1. *
  2. * @see http://php.net/manual/en/streamwrapper.stream-close.php
  3. *
  4. * @return void
  5. */
  6. public function stream_close()

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if (!$this->handle) {
  9. return;
  10. }
  11. self::restorePrev();
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:03:02 GMT
  1. *
  2. * @return boolean
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.stream-eof.php
  5. */
  6. public function stream_eof()

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if (!$this->handle) {
  9. return false;
  10. }
  11. self::restorePrev();
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:02:56 GMT
  1. *
  2. * @return boolean
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.stream-flush.php
  5. */
  6. public function stream_flush()

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if (!$this->handle) {
  9. return false;
  10. }
  11. self::restorePrev();
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:02:50 GMT
  1. *
  2. * @return boolean
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.stream-lock.php
  5. */
  6. public function stream_lock($operation)

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if (!$this->handle) {
  9. return false;
  10. }
  11. self::restorePrev();
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:02:42 GMT
  1. *
  2. * @return boolean
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.stream-metadata.php
  5. */
  6. public function stream_metadata($path, $option, $value)

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. self::restorePrev();
  9. switch ($option) {
  10. case STREAM_META_TOUCH:
  11. if (!empty($value)) {
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:02:35 GMT
  1. * @return boolean
  2. *
  3. * @see http://php.net/manual/en/streamwrapper.stream-open.php
  4. * @throws \UnexpectedValueException
  5. */
  6. public function stream_open($path, $mode, $options, &$openedPath)

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if ($this->handle) {
  9. return false;
  10. }
  11. $useIncludePath = (bool) $options & STREAM_USE_PATH;
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:02:30 GMT
  1. *
  2. * @return string
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.stream-read.php
  5. */
  6. public function stream_read($count)

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if (!$this->handle) {
  9. return false;
  10. }
  11. self::restorePrev();
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:02:25 GMT
  1. *
  2. * @return boolean
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.stream-seek.php
  5. */
  6. public function stream_seek($offset, $whence = SEEK_SET)

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if (!$this->handle) {
  9. return false;
  10. }
  11. self::restorePrev();
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:02:20 GMT
  1. *
  2. * @return array
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.stream-stat.php
  5. */
  6. public function stream_stat()

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if (!$this->handle) {
  9. return false;
  10. }
  11. self::restorePrev();
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:02:14 GMT
  1. *
  2. * @return integer
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.stream-tell.php
  5. */
  6. public function stream_tell()

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if (!$this->handle) {
  9. return false;
  10. }
  11. self::restorePrev();
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:02:10 GMT
  1. *
  2. * @return boolean
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.stream-truncate.php
  5. */
  6. public function stream_truncate($size)

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if (!$this->handle) {
  9. return false;
  10. }
  11. self::restorePrev();
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:02:04 GMT
  1. *
  2. * @return integer
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.stream-write.php
  5. */
  6. public function stream_write($data)

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. if (!$this->handle) {
  9. return false;
  10. }
  11. self::restorePrev();
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:01:57 GMT
  1. *
  2. * @return array
  3. *
  4. * @see http://php.net/manual/en/streamwrapper.url-stat.php
  5. */
  6. public function url_stat($path, $flags)

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. self::restorePrev();
  9. if (!\file_exists($path)) {
  10. $info = false;
  11. } elseif ($flags & STREAM_URL_STAT_LINK) {
  • bkdotcom

    Ignored on Wed, 10 Oct 2018 03:01:47 GMT
  1. /**
  2. * {@inheritDoc}
  3. *
  4. * Requires php >= 5.6 (variadic syntax)
  5. */
  6. public function bind_param($types, &...$vals)

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  7. {
  8. $this->params = $vals;
  9. $this->types = \str_split($types);
  10. return parent::bind_param($types, ...$vals);
  11. }
  • bkdotcom

    Ignored on Thu, 27 Jun 2019 14:21:08 GMT
  1. }
  2. /**
  3. * {@inheritDoc}
  4. */
  5. public function multi_query($query)

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  6. {
  7. return $this->profileCall('multi_query', $query, \func_get_args());
  8. }
  9. /**
  • bkdotcom

    Ignored on Thu, 27 Jun 2019 14:24:42 GMT
  1. }
  2. /**
  3. * {@inheritDoc}
  4. */
  5. public function real_query($query)

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  6. {
  7. return $this->profileCall('real_query', $query, \func_get_args());
  8. }
  9. /**
  • bkdotcom

    Ignored on Thu, 27 Jun 2019 14:21:13 GMT
  1. }
  2. /**
  3. * {@inheritDoc}
  4. */
  5. public function stmt_init()

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Brad Kent
  6. {
  7. return new MySqliStmt($this, null, $this->debug);
  8. }
  9. }
  • bkdotcom

    Ignored on Thu, 27 Jun 2019 14:24:46 GMT