1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VB.NET 4.8.1を今の時代に触る!!PHP 8.x, TypeScript 5.xとの言語仕様比較(付録)

1
Last updated at Posted at 2025-12-27

目次
第18章 リフレクションとメタプログラミング

付録

A. 予約語一覧

PHP 8.x

__halt_compiler  abstract      and           array         as
break            callable      case          catch         class
clone            const         continue      declare       default
die              do            echo          else          elseif
empty            enddeclare    endfor        endforeach    endif
endswitch        endwhile      enum          eval          exit
extends          final         finally       fn            for
foreach          function      global        goto          if
implements       include       include_once  instanceof    insteadof
interface        isset         list          match         namespace
new              or            print         private       protected
public           readonly      require       require_once  return
static           switch        throw         trait         try
unset            use           var           while         xor
yield            yield from

// 型関連
bool    false   float   int     iterable   mixed
never   null    numeric object  parent     self
string  true    void

TypeScript 5.x

// JavaScript 予約語
break       case      catch     class     const
continue    debugger  default   delete    do
else        enum      export    extends   false
finally     for       function  if        import
in          instanceof  new     null      return
super       switch    this      throw     true
try         typeof    var       void      while
with        yield

// TypeScript 追加
abstract    any         as          asserts     async
await       boolean     constructor declare     get
infer       is          keyof       module      namespace
never       number      object      out         override
private     protected   public      readonly    require
set         static      string      symbol      type
undefined   unique      unknown

VB.NET 4.8.1

AddHandler    AddressOf     Alias         And        AndAlso
As            Boolean       ByRef         Byte       ByVal
Call          Case          Catch         CBool      CByte
CChar         CDate         CDbl          CDec       Char
CInt          Class         CLng          CObj       Const
Continue      CSByte        CShort        CSng       CStr
CType         CUInt         CULng         CUShort    Date
Decimal       Declare       Default       Delegate   Dim
DirectCast    Do            Double        Each       Else
ElseIf        End           EndIf         Enum       Erase
Error         Event         Exit          False      Finally
For           Friend        Function      Get        GetType
GetXMLNamespace  Global     GoSub         GoTo       Handles
If            Implements    Imports       In         Inherits
Integer       Interface     Is            IsNot      Let
Lib           Like          Long          Loop       Me
Mod           Module        MustInherit   MustOverride  MyBase
MyClass       Namespace     Narrowing     New        Next
Not           Nothing       NotInheritable  NotOverridable  Object
Of            On            Operator      Option     Optional
Or            OrElse        Out           Overloads  Overridable
Overrides     ParamArray    Partial       Private    Property
Protected     Public        RaiseEvent    ReadOnly   ReDim
REM           RemoveHandler Resume        Return     SByte
Select        Set           Shadows       Shared     Short
Single        Static        Step          Stop       String
Structure     Sub           SyncLock      Then       Throw
To            True          Try           TryCast    TypeOf
UInteger      ULong         UShort        Using      Variant
Wend          When          While         Widening   With
WithEvents    WriteOnly     Xor

B. 演算子優先順位

PHP(高い順)

優先順位 演算子
1 clone, new
2 **
3 ++, --, ~, (int), (float), (string), (array), (object), (bool), @
4 instanceof
5 !
6 *, /, %
7 +, -, .
8 <<, >>
9 <, <=, >, >=
10 ==, !=, ===, !==, <>, <=>
11 &
12 ^
13 |
14 &&
15 ||
16 ??
17 ? :
18 =, +=, -=, *=, /=, .=, %=, **=, &=, |=, ^=, <<=, >>=, ??=
19 yield from
20 yield
21 print
22 and
23 xor
24 or

TypeScript(高い順)

優先順位 演算子
1 (), [], ., ?., !.
2 new(引数あり)
3 new(引数なし)
4 ++, --(後置)
5 !, ~, +, -, ++, --(前置), typeof, void, delete, await
6 **
7 *, /, %
8 +, -
9 <<, >>, >>>
10 <, <=, >, >=, in, instanceof, as
11 ==, !=, ===, !==
12 &
13 ^
14 |
15 &&
16 ||, ??
17 ? :
18 =, +=, -=, *=, /=, %=, **=, <<=, >>=, >>>=, &=, ^=, |=, &&=, ||=, ??=
19 yield, yield*
20 ,

VB.NET(高い順)

優先順位 演算子
1 ^(累乗)
2 +, -(単項)
3 *, /
4 \(整数除算)
5 Mod
6 +, -(二項)
7 &(文字列連結)
8 <<, >>
9 =, <>, <, <=, >, >=, Is, IsNot, Like, TypeOf...Is
10 Not
11 And, AndAlso
12 Or, OrElse
13 Xor

C. 型変換対応表

数値型

変換 PHP TypeScript VB.NET
文字列→整数 (int)$s, intval($s) parseInt(s), Number(s) CInt(s), Integer.Parse(s)
文字列→浮動小数点 (float)$s, floatval($s) parseFloat(s), Number(s) CDbl(s), Double.Parse(s)
整数→文字列 (string)$i, strval($i) String(i), `${i}` CStr(i), i.ToString()
浮動小数点→整数 (int)$f Math.floor(f), Math.trunc(f) CInt(f), Math.Truncate(f)

真偽値変換

PHP TypeScript VB.NET
0 → bool false false(条件式) False
"" → bool false false(条件式) 変換エラー
"0" → bool false true 変換エラー
null → bool false false(条件式) 変換エラー
[] → bool false true N/A
bool → 整数 true1, false0 true1, false0 True-1, False0

配列/コレクション

変換 PHP TypeScript VB.NET
配列→リスト N/A N/A arr.ToList()
リスト→配列 N/A N/A list.ToArray()
配列→文字列 implode(",", $arr) arr.join(",") String.Join(",", arr)
文字列→配列 explode(",", $s) s.split(",") s.Split(","c)
オブジェクト→配列 (array)$obj Object.values(obj) N/A

D. 構文比較早見表

Hello World

<?php echo "Hello, World!";
console.log("Hello, World!");
Console.WriteLine("Hello, World!")

変数宣言

操作 PHP TypeScript VB.NET
変数宣言 $x = 10; let x = 10; Dim x As Integer = 10
定数宣言 const X = 10; const X = 10; Const X As Integer = 10
型注釈 int $x = 10;(プロパティ) let x: number = 10; Dim x As Integer = 10

条件分岐

操作 PHP TypeScript VB.NET
if if ($x) { } if (x) { } If x Then ... End If
else if elseif ($x) { } else if (x) { } ElseIf x Then
switch switch ($x) { case 1: break; } switch (x) { case 1: break; } Select Case x ... End Select
三項演算子 $x ? "yes" : "no" x ? "yes" : "no" If(x, "yes", "no")

ループ

操作 PHP TypeScript VB.NET
for for ($i=0; $i<10; $i++) for (let i=0; i<10; i++) For i = 0 To 9 ... Next
foreach foreach ($arr as $v) for (const v of arr) For Each v In arr ... Next
while while ($x) { } while (x) { } While x ... End While

関数/メソッド

操作 PHP TypeScript VB.NET
関数定義 function f($x) { } function f(x: number) { } Function F(x As Integer)
戻り値型 function f(): int { } function f(): number { } Function F() As Integer
ラムダ fn($x) => $x * 2 (x) => x * 2 Function(x) x * 2
デフォルト引数 function f($x = 10) function f(x = 10) Function F(Optional x = 10)

クラス

操作 PHP TypeScript VB.NET
クラス定義 class C { } class C { } Class C ... End Class
コンストラクタ __construct() constructor() Sub New()
継承 extends extends Inherits
インターフェース implements implements Implements
プロパティ public $x; public x: number; Public Property X As Integer

例外処理

操作 PHP TypeScript VB.NET
try try { } try { } Try ... End Try
catch catch (Exception $e) catch (e) { } Catch ex As Exception
finally finally { } finally { } Finally
throw throw new Exception() throw new Error() Throw New Exception()

Null処理

操作 PHP TypeScript VB.NET
Null合体 $x ?? $default x ?? default If(x, default)
Null条件 $obj?->method() obj?.method() obj?.Method()
Nullable型 ?string string | null String または Integer?

配列操作

操作 PHP TypeScript VB.NET
作成 [1, 2, 3] [1, 2, 3] {1, 2, 3}
追加 $arr[] = 4 arr.push(4) list.Add(4)
map array_map(fn, $arr) arr.map(fn) arr.Select(fn)
filter array_filter($arr, fn) arr.filter(fn) arr.Where(fn)
reduce array_reduce($arr, fn, init) arr.reduce(fn, init) arr.Aggregate(init, fn)

文字列操作

操作 PHP TypeScript VB.NET
連結 $a . $b a + b a & b
補間 "Hello, $name" `Hello, ${name}` $"Hello, {name}"
長さ strlen($s) s.length s.Length
部分文字列 substr($s, 0, 5) s.substring(0, 5) s.Substring(0, 5)
分割 explode(",", $s) s.split(",") s.Split(","c)
結合 implode(",", $arr) arr.join(",") String.Join(",", arr)

目次

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?