Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

There will be changes in PHP 7, that will break backwards compatibility and this is an umbrella discussion so that we can pinpoint and fix all of them.

  1. usages of $this->$property['prop'] (e.g. in kDBList)
  2. usage of references inside foreach
  3. classes having method named the same as class name (the PHP4 constructor) are now

...

  1. deprecated
  2. usage of $HTTP_RAW_POST_DATA

...

 

...

Solution

The following BASH script can be used to detect some of potentially problematic places:

Code Block
languagebash
#!/usr/bin/env bash

# Credits for regular expressions goes to Adam Harvey (@LGnome).
case "$1" in
   indirect_references)
      REGEXP='((((::)|(->))\$[a-zA-Z_][a-zA-Z0-9_]*)+\[[^\s]+\]\(\))|(->\$[a-zA-Z_][a-zA-Z0-9_]*\[)|(\$\$[a-zA-Z_][a-zA-Z0-9_]*\[)'
      ;;
   engine_exceptions)
      REGEXP='catch\s*\(\\?Exception\s'
      ;;
   foreach)
      REGEXP='foreach.*\sas\s+&'
      ;;
   *)
      echo $"Usage: $0 {indirect_references|engine_exceptions|foreach} {folder}"
      exit 1

esac

if [ $# -eq 1 ]; then
   FOLDER="."
else
   FOLDER=$2
fi

find $FOLDER -type f -name "*.php" -not -path "*/vendor/*" -print0 | pv | xargs --null grep --color=always --line-number -E $REGEXP 

Related Tasks

Jira Legacy
serverSystem Jira
serverId513b375f-8291-3313-9d9f-704c39b1f915
keyINP-1436

Jira Legacy
serverSystem Jira
serverId513b375f-8291-3313-9d9f-704c39b1f915
keyINP-1641