<?php
$lines = array(
  '84951234567',
  '+74951234567',
  '8-495-1-234-567',
  '8 (8122) 56-56-56',
  ' 8-911-1234567',
  '8 (911) 12 345 67',
  '8-911 12 345 67',
  '8 (911) - 123 - 45 - 67',
  '+ 7 999 123 4567',
  '8 ( 909 ) 1234567',
  '8 999 123 4567',
  '8 952-58 -51 25-5',
  '02',
  '84951234567 позвать люсю',
  '849512345',
  '849512345678',
  '8 (409) 123-123-123',
  '7900123467',
  '5005005001',
  '8888-8888-88',
  '84951a234567',
  '8495123456a',
  '+1 234 5678901',
  '+8 234 5678901',
  '7 234 5678901'
);

foreach($lines as $key => $phoneNumber) {
  if($number = preg_replace(["/^\\s*\\+\\s*7/", "/[\\(\\)\\-\\s]/", "/^[^8].*/", "/.*?[^\d].*/", "/^[0-9]{12,}$/", "/^[0-9]{1,10}$/"], ["8", ""], $phoneNumber)) {
    echo "#".str_pad($key, 2)." phone number: ".$number.PHP_EOL;
  } else {
    echo "#".str_pad($key, 2)." wrong format!".PHP_EOL;
  }
}